Adds fix for issue affecting update with CLP (#5269)
* Adds fix for issue affecting update with CLP * Disable single instance
This commit is contained in:
@@ -834,7 +834,6 @@ describe('Parse.User testing', () => {
|
|||||||
query.get(user.id).then(freshUser => {
|
query.get(user.id).then(freshUser => {
|
||||||
equal(freshUser.id, user.id);
|
equal(freshUser.id, user.id);
|
||||||
equal(freshUser.get('username'), 'alice');
|
equal(freshUser.get('username'), 'alice');
|
||||||
Parse.Object.enableSingleInstance();
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -860,7 +859,6 @@ describe('Parse.User testing', () => {
|
|||||||
equal(freshUser.id, user.id);
|
equal(freshUser.id, user.id);
|
||||||
// Should be alice, but it depends on batch support.
|
// Should be alice, but it depends on batch support.
|
||||||
equal(freshUser.get('username'), 'bob');
|
equal(freshUser.get('username'), 'bob');
|
||||||
Parse.Object.enableSingleInstance();
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -1275,14 +1273,12 @@ describe('Parse.User testing', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('returns authData when authed and logged in with provider (regression test for #1498)', async done => {
|
it('returns authData when authed and logged in with provider (regression test for #1498)', async done => {
|
||||||
Parse.Object.enableSingleInstance();
|
|
||||||
const provider = getMockFacebookProvider();
|
const provider = getMockFacebookProvider();
|
||||||
Parse.User._registerAuthenticationProvider(provider);
|
Parse.User._registerAuthenticationProvider(provider);
|
||||||
const user = await Parse.User._logInWith('facebook');
|
const user = await Parse.User._logInWith('facebook');
|
||||||
const userQuery = new Parse.Query(Parse.User);
|
const userQuery = new Parse.Query(Parse.User);
|
||||||
userQuery.get(user.id).then(user => {
|
userQuery.get(user.id).then(user => {
|
||||||
expect(user.get('authData')).not.toBeUndefined();
|
expect(user.get('authData')).not.toBeUndefined();
|
||||||
Parse.Object.disableSingleInstance();
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1066,7 +1066,6 @@ describe('SchemaController', () => {
|
|||||||
.then(obj2reloaded => {
|
.then(obj2reloaded => {
|
||||||
expect(obj2reloaded.get('aString')).toEqual(undefined);
|
expect(obj2reloaded.get('aString')).toEqual(undefined);
|
||||||
done();
|
done();
|
||||||
Parse.Object.enableSingleInstance();
|
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
@@ -1100,7 +1099,6 @@ describe('SchemaController', () => {
|
|||||||
.then(obj1 => {
|
.then(obj1 => {
|
||||||
expect(obj1.get('aPointer')).toEqual('Now a string');
|
expect(obj1.get('aPointer')).toEqual('Now a string');
|
||||||
done();
|
done();
|
||||||
Parse.Object.enableSingleInstance();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -2043,6 +2043,23 @@ describe('schemas', () => {
|
|||||||
.catch(done.fail);
|
.catch(done.fail);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('regression test for #5177', async () => {
|
||||||
|
Parse.Object.disableSingleInstance();
|
||||||
|
Parse.Cloud.beforeSave('AClass', () => {});
|
||||||
|
await setPermissionsOnClass(
|
||||||
|
'AClass',
|
||||||
|
{
|
||||||
|
update: { '*': true },
|
||||||
|
},
|
||||||
|
false
|
||||||
|
);
|
||||||
|
const obj = new Parse.Object('AClass');
|
||||||
|
await obj.save({ key: 1 }, { useMasterKey: true });
|
||||||
|
obj.increment('key', 10);
|
||||||
|
const objectAgain = await obj.save();
|
||||||
|
expect(objectAgain.get('key')).toBe(11);
|
||||||
|
});
|
||||||
|
|
||||||
it('regression test for #2246', done => {
|
it('regression test for #2246', done => {
|
||||||
const profile = new Parse.Object('UserProfile');
|
const profile = new Parse.Object('UserProfile');
|
||||||
const user = new Parse.User();
|
const user = new Parse.User();
|
||||||
|
|||||||
@@ -1141,7 +1141,6 @@ class DatabaseController {
|
|||||||
distinct,
|
distinct,
|
||||||
pipeline,
|
pipeline,
|
||||||
readPreference,
|
readPreference,
|
||||||
isWrite,
|
|
||||||
}: any = {}
|
}: any = {}
|
||||||
): Promise<any> {
|
): Promise<any> {
|
||||||
const isMaster = acl === undefined;
|
const isMaster = acl === undefined;
|
||||||
@@ -1217,7 +1216,7 @@ class DatabaseController {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (!query) {
|
if (!query) {
|
||||||
if (op == 'get') {
|
if (op === 'get') {
|
||||||
throw new Parse.Error(
|
throw new Parse.Error(
|
||||||
Parse.Error.OBJECT_NOT_FOUND,
|
Parse.Error.OBJECT_NOT_FOUND,
|
||||||
'Object not found.'
|
'Object not found.'
|
||||||
@@ -1227,7 +1226,7 @@ class DatabaseController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!isMaster) {
|
if (!isMaster) {
|
||||||
if (isWrite) {
|
if (op === 'update' || op === 'delete') {
|
||||||
query = addWriteACL(query, aclGroup);
|
query = addWriteACL(query, aclGroup);
|
||||||
} else {
|
} else {
|
||||||
query = addReadACL(query, aclGroup);
|
query = addReadACL(query, aclGroup);
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ function RestQuery(
|
|||||||
this.clientSDK = clientSDK;
|
this.clientSDK = clientSDK;
|
||||||
this.response = null;
|
this.response = null;
|
||||||
this.findOptions = {};
|
this.findOptions = {};
|
||||||
this.isWrite = false;
|
|
||||||
|
|
||||||
if (!this.auth.isMaster) {
|
if (!this.auth.isMaster) {
|
||||||
if (this.className == '_Session') {
|
if (this.className == '_Session') {
|
||||||
@@ -259,12 +258,6 @@ RestQuery.prototype.buildRestWhere = function() {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// Marks the query for a write attempt, so we read the proper ACL (write instead of read)
|
|
||||||
RestQuery.prototype.forWrite = function() {
|
|
||||||
this.isWrite = true;
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Uses the Auth object to get the list of roles, adds the user id
|
// Uses the Auth object to get the list of roles, adds the user id
|
||||||
RestQuery.prototype.getUserAndRoleACL = function() {
|
RestQuery.prototype.getUserAndRoleACL = function() {
|
||||||
if (this.auth.isMaster) {
|
if (this.auth.isMaster) {
|
||||||
@@ -647,9 +640,6 @@ RestQuery.prototype.runFind = function(options = {}) {
|
|||||||
if (options.op) {
|
if (options.op) {
|
||||||
findOptions.op = options.op;
|
findOptions.op = options.op;
|
||||||
}
|
}
|
||||||
if (this.isWrite) {
|
|
||||||
findOptions.isWrite = true;
|
|
||||||
}
|
|
||||||
return this.config.database
|
return this.config.database
|
||||||
.find(this.className, this.restWhere, findOptions)
|
.find(this.className, this.restWhere, findOptions)
|
||||||
.then(results => {
|
.then(results => {
|
||||||
|
|||||||
@@ -112,7 +112,6 @@ function del(config, auth, className, objectId) {
|
|||||||
const hasLiveQuery = checkLiveQuery(className, config);
|
const hasLiveQuery = checkLiveQuery(className, config);
|
||||||
if (hasTriggers || hasLiveQuery || className == '_Session') {
|
if (hasTriggers || hasLiveQuery || className == '_Session') {
|
||||||
return new RestQuery(config, auth, className, { objectId })
|
return new RestQuery(config, auth, className, { objectId })
|
||||||
.forWrite()
|
|
||||||
.execute({ op: 'delete' })
|
.execute({ op: 'delete' })
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (response && response.results && response.results.length) {
|
if (response && response.results && response.results.length) {
|
||||||
@@ -224,9 +223,9 @@ function update(config, auth, className, restWhere, restObject, clientSDK) {
|
|||||||
const hasLiveQuery = checkLiveQuery(className, config);
|
const hasLiveQuery = checkLiveQuery(className, config);
|
||||||
if (hasTriggers || hasLiveQuery) {
|
if (hasTriggers || hasLiveQuery) {
|
||||||
// Do not use find, as it runs the before finds
|
// Do not use find, as it runs the before finds
|
||||||
return new RestQuery(config, auth, className, restWhere)
|
return new RestQuery(config, auth, className, restWhere).execute({
|
||||||
.forWrite()
|
op: 'update',
|
||||||
.execute();
|
});
|
||||||
}
|
}
|
||||||
return Promise.resolve({});
|
return Promise.resolve({});
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user