From e4bb803cc72949bb11498a2dbb6323907435fe16 Mon Sep 17 00:00:00 2001 From: Diamond Lewis Date: Wed, 31 May 2017 18:46:26 -0500 Subject: [PATCH 1/4] Add bytes to schema --- src/Adapters/Storage/Mongo/MongoSchemaCollection.js | 1 + src/Controllers/SchemaController.js | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Adapters/Storage/Mongo/MongoSchemaCollection.js b/src/Adapters/Storage/Mongo/MongoSchemaCollection.js index e6dbd4ae18..46d8a50839 100644 --- a/src/Adapters/Storage/Mongo/MongoSchemaCollection.js +++ b/src/Adapters/Storage/Mongo/MongoSchemaCollection.js @@ -97,6 +97,7 @@ function parseFieldTypeToMongoFieldType({ type, targetClass }) { case 'Array': return 'array'; case 'GeoPoint': return 'geopoint'; case 'File': return 'file'; + case 'Bytes': return 'bytes'; } } diff --git a/src/Controllers/SchemaController.js b/src/Controllers/SchemaController.js index a16a59571a..f29763be04 100644 --- a/src/Controllers/SchemaController.js +++ b/src/Controllers/SchemaController.js @@ -216,6 +216,7 @@ const validNonRelationOrPointerTypes = [ 'Array', 'GeoPoint', 'File', + 'Bytes' ]; // Returns an error suitable for throwing if the type is invalid const fieldTypeIsInvalid = ({ type, targetClass }) => { @@ -966,7 +967,7 @@ function getObjectType(obj) { break; case 'Bytes' : if(obj.base64) { - return; + return 'Bytes'; } break; } From 3ae015b1dbf613c0d763a0debfb0301bd220448d Mon Sep 17 00:00:00 2001 From: Diamond Lewis Date: Wed, 31 May 2017 18:57:37 -0500 Subject: [PATCH 2/4] postgres support --- src/Adapters/Storage/Postgres/PostgresStorageAdapter.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js b/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js index cd82ade4b5..778b112865 100644 --- a/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js +++ b/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js @@ -28,6 +28,7 @@ const parseTypeToPostgresType = type => { case 'Pointer': return 'char(10)'; case 'Number': return 'double precision'; case 'GeoPoint': return 'point'; + case 'Bytes': return 'jsonb'; case 'Array': if (type.contents && type.contents.type === 'String') { return 'text[]'; @@ -769,6 +770,7 @@ export class PostgresStorageAdapter { } break; case 'Object': + case 'Bytes': case 'String': case 'Number': case 'Boolean': From 0b2eeb3692cbecf8d0056f70af87a89b65403b54 Mon Sep 17 00:00:00 2001 From: Diamond Lewis Date: Wed, 31 May 2017 19:11:01 -0500 Subject: [PATCH 3/4] test cases --- spec/Schema.spec.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/Schema.spec.js b/spec/Schema.spec.js index 3329bd4bfc..8bbe9dacfa 100644 --- a/spec/Schema.spec.js +++ b/spec/Schema.spec.js @@ -523,6 +523,7 @@ describe('SchemaController', () => { aFile: {type: 'File'}, aPointer: {type: 'Pointer', targetClass: 'ThisClassDoesNotExistYet'}, aRelation: {type: 'Relation', targetClass: 'NewClass'}, + aBytes: {type: 'Bytes'}, })) .then(actualSchema => { const expectedSchema = { @@ -542,6 +543,7 @@ describe('SchemaController', () => { aFile: { type: 'File' }, aPointer: { type: 'Pointer', targetClass: 'ThisClassDoesNotExistYet' }, aRelation: { type: 'Relation', targetClass: 'NewClass' }, + aBytes: {type: 'Bytes'}, }, classLevelPermissions: { find: { '*': true }, From b5d6f8f9a313583450b50ca0649d0717052283a1 Mon Sep 17 00:00:00 2001 From: Diamond Lewis Date: Wed, 31 May 2017 21:05:34 -0500 Subject: [PATCH 4/4] bytes work parse object --- spec/ParseObject.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/ParseObject.spec.js b/spec/ParseObject.spec.js index 4afc48c4cc..da8ee45217 100644 --- a/spec/ParseObject.spec.js +++ b/spec/ParseObject.spec.js @@ -1328,7 +1328,7 @@ describe('Parse.Object testing', () => { }); }); - it_exclude_dbs(['postgres'])("bytes work", function(done) { + it("bytes work", function(done) { Parse.Promise.as().then(function() { var obj = new TestObject(); obj.set("bytes", { __type: "Bytes", base64: "ZnJveW8=" });