5 new methods: undelete, set_restriction, get_primary_value, join, without_callbacks and with inside with#180
Open
julienmru wants to merge 16 commits intojamierumbelow:masterfrom
Open
5 new methods: undelete, set_restriction, get_primary_value, join, without_callbacks and with inside with#180julienmru wants to merge 16 commits intojamierumbelow:masterfrom
julienmru wants to merge 16 commits intojamierumbelow:masterfrom
Conversation
Allows undeletions when soft delete is enabled.
Use-case: controller’s constructor loads a model, adds a restriction (eg. “user_id = 123”), subsequent calls to the model add the restriction to all the queries. Think of it as an easy built-in security which removes the need to add the same where clause again and again on all methods.
skipping soft_delete condition when called from delete (so that we can pass unit tests)
Changing unit test following earlier fix
Author
|
This pull request also fixes #87. |
Owner
|
Hi Julien, Thanks for your PR and email. I promise I'll take a look soon, I'm just J On 7 August 2014 12:28, Julien Tessier notifications@github.com wrote:
Jamie Rumbelow |
- like with_deleted() function, without_restriction() temporarly includes restricted rows - with_deleted() was not temporary and was maintained between model calls — not sure if it was on purpose or not, but this is fixed: with_deleted() only works for the current call.
Author
|
I changed something in with_deleted(): contrary to the var name, it was not temporary and was maintained between calls. I'm not sure if it was on purpose or not, but this is changed: with_deleted() only works for the current call. |
if restrictions are enabled, truncate is rewritten to delete so that records which the user has no access to are not deleted
Possibility to retrieve the current primary key value, eg. in observers.
Adds a method to do a direct ActiveRecord join, eg:
$this->photo_model->join('photos_selections', 'ps_photo = p_id',
'left')->get_many_by('p_album', $id)
Code cleanup
This reverts commit 7ca6900.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
undelete: pretty self-explanatory, works only when soft deleting is enabledset_restriction: use-case: controller’s constructor loads a model, adds a restriction (eg. “user_id = 123”), subsequent calls to the model add the restriction to all the queries. Think of it as an easy built-in security which removes the need to add the same where clause again and again on all methods.get_primary_value: gets the current primary key value, useful in observersjoin: performs a direct ActiveRecord joinwithnow accepts a second parameter which behaves like a with() inside the get()without_callbacks: temporarly disable callbacks