feat(postgres): Add Bytes to Support (#3894)
* Add bytes to schema * postgres support * test cases * bytes work parse object
This commit is contained in:
committed by
Florent Vilmart
parent
e8be98ded2
commit
4b16a72992
@@ -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() {
|
Parse.Promise.as().then(function() {
|
||||||
var obj = new TestObject();
|
var obj = new TestObject();
|
||||||
obj.set("bytes", { __type: "Bytes", base64: "ZnJveW8=" });
|
obj.set("bytes", { __type: "Bytes", base64: "ZnJveW8=" });
|
||||||
|
|||||||
@@ -523,6 +523,7 @@ describe('SchemaController', () => {
|
|||||||
aFile: {type: 'File'},
|
aFile: {type: 'File'},
|
||||||
aPointer: {type: 'Pointer', targetClass: 'ThisClassDoesNotExistYet'},
|
aPointer: {type: 'Pointer', targetClass: 'ThisClassDoesNotExistYet'},
|
||||||
aRelation: {type: 'Relation', targetClass: 'NewClass'},
|
aRelation: {type: 'Relation', targetClass: 'NewClass'},
|
||||||
|
aBytes: {type: 'Bytes'},
|
||||||
}))
|
}))
|
||||||
.then(actualSchema => {
|
.then(actualSchema => {
|
||||||
const expectedSchema = {
|
const expectedSchema = {
|
||||||
@@ -542,6 +543,7 @@ describe('SchemaController', () => {
|
|||||||
aFile: { type: 'File' },
|
aFile: { type: 'File' },
|
||||||
aPointer: { type: 'Pointer', targetClass: 'ThisClassDoesNotExistYet' },
|
aPointer: { type: 'Pointer', targetClass: 'ThisClassDoesNotExistYet' },
|
||||||
aRelation: { type: 'Relation', targetClass: 'NewClass' },
|
aRelation: { type: 'Relation', targetClass: 'NewClass' },
|
||||||
|
aBytes: {type: 'Bytes'},
|
||||||
},
|
},
|
||||||
classLevelPermissions: {
|
classLevelPermissions: {
|
||||||
find: { '*': true },
|
find: { '*': true },
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ function parseFieldTypeToMongoFieldType({ type, targetClass }) {
|
|||||||
case 'Array': return 'array';
|
case 'Array': return 'array';
|
||||||
case 'GeoPoint': return 'geopoint';
|
case 'GeoPoint': return 'geopoint';
|
||||||
case 'File': return 'file';
|
case 'File': return 'file';
|
||||||
|
case 'Bytes': return 'bytes';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ const parseTypeToPostgresType = type => {
|
|||||||
case 'Pointer': return 'char(10)';
|
case 'Pointer': return 'char(10)';
|
||||||
case 'Number': return 'double precision';
|
case 'Number': return 'double precision';
|
||||||
case 'GeoPoint': return 'point';
|
case 'GeoPoint': return 'point';
|
||||||
|
case 'Bytes': return 'jsonb';
|
||||||
case 'Array':
|
case 'Array':
|
||||||
if (type.contents && type.contents.type === 'String') {
|
if (type.contents && type.contents.type === 'String') {
|
||||||
return 'text[]';
|
return 'text[]';
|
||||||
@@ -769,6 +770,7 @@ export class PostgresStorageAdapter {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'Object':
|
case 'Object':
|
||||||
|
case 'Bytes':
|
||||||
case 'String':
|
case 'String':
|
||||||
case 'Number':
|
case 'Number':
|
||||||
case 'Boolean':
|
case 'Boolean':
|
||||||
|
|||||||
@@ -216,6 +216,7 @@ const validNonRelationOrPointerTypes = [
|
|||||||
'Array',
|
'Array',
|
||||||
'GeoPoint',
|
'GeoPoint',
|
||||||
'File',
|
'File',
|
||||||
|
'Bytes'
|
||||||
];
|
];
|
||||||
// Returns an error suitable for throwing if the type is invalid
|
// Returns an error suitable for throwing if the type is invalid
|
||||||
const fieldTypeIsInvalid = ({ type, targetClass }) => {
|
const fieldTypeIsInvalid = ({ type, targetClass }) => {
|
||||||
@@ -966,7 +967,7 @@ function getObjectType(obj) {
|
|||||||
break;
|
break;
|
||||||
case 'Bytes' :
|
case 'Bytes' :
|
||||||
if(obj.base64) {
|
if(obj.base64) {
|
||||||
return;
|
return 'Bytes';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user