Skip to content

Conversation

vitaly-t
Copy link
Contributor

Method setClassLevelPermissions should use .task to share the connection for the two consecutive operations. It doesn't need a transaction, because the first operation does not need to roll back when the second one fails.

Method `setClassLevelPermissions` should use `.task` to share the connection for the two consecutive operations. It doesn't need a transaction, because the first operation does not need to roll back when the second one fails.
const self = this;
return this._client.task('set-class-level-permissions', function * (t) {
yield self._ensureSchemaCollectionExists(t);
const values = [className, 'schema', 'classLevelPermissions', JSON.stringify(CLPs)];
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we extract the values out of the generator?

Copy link
Contributor Author

@vitaly-t vitaly-t Dec 26, 2017

Choose a reason for hiding this comment

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

@flovilmart No. This is one of so many now refactored lines where the end result is returned from .none which resolves with null, in order to chain it to the result of the task/transaction, so if the last query fails - we get the correct error. But when we replace it with yield, the errors are thrown, and thus chained to the result automatically, so you do not need to return the value when the callers do not care about the value, only whether it is success or error, i.e. with the last yield you only do return when the resolved value from the task/transaction matters.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@flovilmart If this is ok, then please review it, as I've got another one ready to go. I'm on a roll this Christmas 😄

@codecov
Copy link

codecov bot commented Dec 26, 2017

Codecov Report

Merging #4460 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4460      +/-   ##
==========================================
+ Coverage   92.66%   92.68%   +0.01%     
==========================================
  Files         118      118              
  Lines        8349     8351       +2     
==========================================
+ Hits         7737     7740       +3     
+ Misses        612      611       -1
Impacted Files Coverage Δ
...dapters/Storage/Postgres/PostgresStorageAdapter.js 96.93% <100%> (ø) ⬆️
src/RestWrite.js 93.46% <0%> (+0.18%) ⬆️

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 a868bed...67a898e. Read the comment docs.

@flovilmart
Copy link
Contributor

All good!

@vitaly-t vitaly-t merged commit 820ae2b into master Dec 27, 2017
@vitaly-t vitaly-t deleted the vitaly-t-patch-1 branch December 27, 2017 00:30
@montymxb
Copy link
Contributor

@vitaly-t just flipping through these now, seems I missed the sudden influx of Xmas PRs 😄 , thanks!

@vitaly-t
Copy link
Contributor Author

@montymxb just my notion of the Christmas spirit 😄

flovilmart pushed a commit that referenced this pull request Dec 29, 2017
Method `setClassLevelPermissions` should use `.task` to share the connection for the two consecutive operations. It doesn't need a transaction, because the first operation does not need to roll back when the second one fails.
UnderratedDev pushed a commit to UnderratedDev/parse-server that referenced this pull request Mar 21, 2020
Method `setClassLevelPermissions` should use `.task` to share the connection for the two consecutive operations. It doesn't need a transaction, because the first operation does not need to roll back when the second one fails.
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