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

Read preference option #3865

Merged
merged 1 commit into from
Jun 21, 2017

Conversation

davimacedo
Copy link
Member

No description provided.

src/rest.js Outdated
enforceRoleSecurity('get', className, auth);
const query = new RestQuery(config, auth, className, { objectId }, restOptions, clientSDK);
return query.execute();
return triggers.maybeRunQueryTrigger(triggers.Types.beforeFind, className, restWhere, restOptions, config, auth).then((result) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should probably make the difference between a get and a find here (as they yield different results)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be useful but it will be annoying. We don't have a safe way to be 100% sure that the frontend is trying to do a get and not a find. The js SDK uses the find endpoint for getting (https://github.com/parse-community/Parse-SDK-JS/blob/master/src/ParseQuery.js#L284). That's why this test (https://github.com/parse-community/parse-server/blob/master/spec/CloudCode.spec.js#L117) already works in the master without this change but this new one (https://github.com/parse-community/parse-server/pull/3865/files#diff-57110aba585acf52c5d9209a61443a8eR1309) doesnt. Therefore I think the best way for someone to check if it is a get or a find is by checking if the where query contains only objectId among the keys.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This si a Parse.Query so that makes sense it's a find, I was thinking more of the fetches, or all the calls that start with a get (where we can know it came from the 'get' endpoints, and not on the 'find' endpoints)
Also, we need to be sure as we have CLP that are based on GET vs FIND :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Im convinced :)
Just done

obj1.set('boolKey', true);

Parse.Object.saveAll([obj0, obj1]).then(() => {
const hook = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davimacedo why don't you just put a spy on the database.serverConfig.cursor and validate the spy later on (you can get all arguments etc...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied the same idea of mongo driver :) (https://github.com/mongodb/node-mongodb-native/blob/2.2/test/functional/readpreference_tests.js)
But I agree it is better with spy. Just improved.

const ReadPreference = require('mongodb').ReadPreference;
const rp = require('request-promise');

describe('Read preference option', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be a describe_only_db('mongo'), not sure it applies to PG yet. That will alleviate confusion.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

};
spyOn(hook, 'method').and.callThrough();

const cursor = databaseAdapter.database.serverConfig.cursor;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the databaseAdapter should probably be acquired by new Config('test').databaseController.adapter

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@davimacedo davimacedo force-pushed the readPreferenceOption branch from 03c4da4 to 2a30943 Compare May 30, 2017 12:48
@codecov
Copy link

codecov bot commented May 30, 2017

Codecov Report

Merging #3865 into master will increase coverage by 0.01%.
The diff coverage is 94.23%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3865      +/-   ##
==========================================
+ Coverage   90.55%   90.56%   +0.01%     
==========================================
  Files         115      115              
  Lines        7741     7783      +42     
==========================================
+ Hits         7010     7049      +39     
- Misses        731      734       +3
Impacted Files Coverage Δ
src/triggers.js 90.4% <100%> (+0.45%) ⬆️
src/RestQuery.js 95.16% <100%> (+0.21%) ⬆️
src/Adapters/Storage/Mongo/MongoCollection.js 95.12% <100%> (ø) ⬆️
src/Controllers/DatabaseController.js 94.36% <100%> (ø) ⬆️
src/Adapters/Storage/Mongo/MongoStorageAdapter.js 92.02% <84.21%> (-0.97%) ⬇️
...dapters/Storage/Postgres/PostgresStorageAdapter.js 96.15% <0%> (-0.13%) ⬇️
src/RestWrite.js 93.29% <0%> (ø) ⬆️
src/Adapters/Auth/meetup.js 89.47% <0%> (+5.26%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 422723f...210658f. Read the comment docs.

@davimacedo davimacedo force-pushed the readPreferenceOption branch from 2a30943 to 025a451 Compare June 12, 2017 15:24
@flovilmart
Copy link
Contributor

This is looking great! Just needs a small rebase to integrate the lastest changes from master!

flovilmart
flovilmart previously approved these changes Jun 14, 2017
@flovilmart
Copy link
Contributor

@davimacedo bump?

@davimacedo
Copy link
Member Author

Sorry about the delay. Just done.

@flovilmart
Copy link
Contributor

@davimacedo looks like it needs another rebase unfortunately :/

@davimacedo davimacedo force-pushed the readPreferenceOption branch from b6ca0ff to 87ba42a Compare June 21, 2017 19:21
@davimacedo davimacedo force-pushed the readPreferenceOption branch from 87ba42a to 210658f Compare June 21, 2017 19:49
@davimacedo
Copy link
Member Author

Done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants