On Wednesday, November 7, 2012 7:21:38 AM UTC-8, Robert Sosinski wrote:
>
> Hey Jeremy,
>
> With Sequel and Postgres, I can do the following:
>
> DB[:people].where(:id => 1).returning('*'.lit).update(:first_name =>
> 'Alice')
>
> This lets me update the record and get back the row from the database
> after triggers. Would it be possible plug the `returning` method into the
> save method when using updates? If it is more complicated then that, could
> you let me know why.
>
> Really appreciate the help.
>
It's not more complicated than that. You probably want to override
Model#_update_dataset to do super.returning('*'.lit) and
Model#_update_without_checking to do (s = super; set_values(s.first);
s.length). That's pretty trivial to do using a plugin (or just adding the
instance methods to Sequel::Model), which is the route I suggest you take
if you don't want to have a separate query to refresh.
Jeremy
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/sequel-talk/-/acHYRkz6000J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sequel-talk?hl=en.