Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Bytes to Schema #3894

Merged
merged 7 commits into from
Jun 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion spec/ParseObject.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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=" });
Expand Down
2 changes: 2 additions & 0 deletions spec/Schema.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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 },
Expand Down
1 change: 1 addition & 0 deletions src/Adapters/Storage/Mongo/MongoSchemaCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ function parseFieldTypeToMongoFieldType({ type, targetClass }) {
case 'Array': return 'array';
case 'GeoPoint': return 'geopoint';
case 'File': return 'file';
case 'Bytes': return 'bytes';
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/Adapters/Storage/Postgres/PostgresStorageAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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[]';
Expand Down Expand Up @@ -769,6 +770,7 @@ export class PostgresStorageAdapter {
}
break;
case 'Object':
case 'Bytes':
case 'String':
case 'Number':
case 'Boolean':
Expand Down
3 changes: 2 additions & 1 deletion src/Controllers/SchemaController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand Down Expand Up @@ -966,7 +967,7 @@ function getObjectType(obj) {
break;
case 'Bytes' :
if(obj.base64) {
return;
return 'Bytes';
}
break;
}
Expand Down