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

5 new methods: undelete, set_restriction, get_primary_value, join, without_callbacks and with inside with #180

Open
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

julienmru
Copy link

undelete: pretty self-explanatory, works only when soft deleting is enabled
set_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 observers
join: performs a direct ActiveRecord join
with now accepts a second parameter which behaves like a with() inside the get()
without_callbacks: temporarly disable callbacks

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
@julienmru
Copy link
Author

This pull request also fixes #87.

@jamierumbelow
Copy link
Owner

Hi Julien,

Thanks for your PR and email. I promise I'll take a look soon, I'm just
manically busy at the moment – I'll get in touch when I've got enough time
to sit down and take a proper look.

J

On 7 August 2014 12:28, Julien Tessier [email protected] wrote:

This pull request also fixes #87
#87.


Reply to this email directly or view it on GitHub
#180 (comment)
.

Jamie Rumbelow
[email protected]

- 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.
@julienmru
Copy link
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.
@julienmru julienmru changed the title 2 new functions: undelete and set_restriction 3, new functions: undelete, set_restriction and get_primary_value Aug 13, 2014
@julienmru julienmru changed the title 3, new functions: undelete, set_restriction and get_primary_value 3 new functions: undelete, set_restriction and get_primary_value Aug 13, 2014
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)
@julienmru julienmru changed the title 3 new functions: undelete, set_restriction and get_primary_value 4 new methods: undelete, set_restriction, get_primary_value and join Aug 14, 2014
@julienmru julienmru changed the title 4 new methods: undelete, set_restriction, get_primary_value and join 4 new methods: undelete, set_restriction, get_primary_value, join and with inside with Aug 25, 2014
@julienmru julienmru changed the title 4 new methods: undelete, set_restriction, get_primary_value, join and with inside with 5 new methods: undelete, set_restriction, get_primary_value, join, without_callbacks and with inside with Sep 5, 2014
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.

None yet

2 participants