Skip to content

Commit 4b16a72

Browse files
dplewisflovilmart
authored andcommitted
feat(postgres): Add Bytes to Support (#3894)
* Add bytes to schema * postgres support * test cases * bytes work parse object
1 parent e8be98d commit 4b16a72

File tree

5 files changed

+8
-2
lines changed

5 files changed

+8
-2
lines changed

spec/ParseObject.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1328,7 +1328,7 @@ describe('Parse.Object testing', () => {
13281328
});
13291329
});
13301330

1331-
it_exclude_dbs(['postgres'])("bytes work", function(done) {
1331+
it("bytes work", function(done) {
13321332
Parse.Promise.as().then(function() {
13331333
var obj = new TestObject();
13341334
obj.set("bytes", { __type: "Bytes", base64: "ZnJveW8=" });

spec/Schema.spec.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,7 @@ describe('SchemaController', () => {
523523
aFile: {type: 'File'},
524524
aPointer: {type: 'Pointer', targetClass: 'ThisClassDoesNotExistYet'},
525525
aRelation: {type: 'Relation', targetClass: 'NewClass'},
526+
aBytes: {type: 'Bytes'},
526527
}))
527528
.then(actualSchema => {
528529
const expectedSchema = {
@@ -542,6 +543,7 @@ describe('SchemaController', () => {
542543
aFile: { type: 'File' },
543544
aPointer: { type: 'Pointer', targetClass: 'ThisClassDoesNotExistYet' },
544545
aRelation: { type: 'Relation', targetClass: 'NewClass' },
546+
aBytes: {type: 'Bytes'},
545547
},
546548
classLevelPermissions: {
547549
find: { '*': true },

src/Adapters/Storage/Mongo/MongoSchemaCollection.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ function parseFieldTypeToMongoFieldType({ type, targetClass }) {
9797
case 'Array': return 'array';
9898
case 'GeoPoint': return 'geopoint';
9999
case 'File': return 'file';
100+
case 'Bytes': return 'bytes';
100101
}
101102
}
102103

src/Adapters/Storage/Postgres/PostgresStorageAdapter.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const parseTypeToPostgresType = type => {
2828
case 'Pointer': return 'char(10)';
2929
case 'Number': return 'double precision';
3030
case 'GeoPoint': return 'point';
31+
case 'Bytes': return 'jsonb';
3132
case 'Array':
3233
if (type.contents && type.contents.type === 'String') {
3334
return 'text[]';
@@ -769,6 +770,7 @@ export class PostgresStorageAdapter {
769770
}
770771
break;
771772
case 'Object':
773+
case 'Bytes':
772774
case 'String':
773775
case 'Number':
774776
case 'Boolean':

src/Controllers/SchemaController.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ const validNonRelationOrPointerTypes = [
216216
'Array',
217217
'GeoPoint',
218218
'File',
219+
'Bytes'
219220
];
220221
// Returns an error suitable for throwing if the type is invalid
221222
const fieldTypeIsInvalid = ({ type, targetClass }) => {
@@ -966,7 +967,7 @@ function getObjectType(obj) {
966967
break;
967968
case 'Bytes' :
968969
if(obj.base64) {
969-
return;
970+
return 'Bytes';
970971
}
971972
break;
972973
}

0 commit comments

Comments
 (0)