On Thursday, November 20, 2014 10:06:05 AM UTC-8, Santiago Doldan wrote:
>
> Is somebody having the same issue?
>
> Sequel does not change the object in memory back to its previous state,
> the user record didn't get stored in the db.
>
> Sequel:
> u = User.new
> u.new? # true
> u.id # nil
> Sequel::Model.db.transaction { u.save; raise Sequel::Rollback }
> u.new? # false
> u.id # 1
>
>
This is expected behavior. If you are rolling back a transaction, you need
to recreate any new objects.
If you really want to reuse the same object, you could add an
after_rollback hook that resets the new? state of the instance and removes
the primary key, and undoes anything done in the before_create/before_save
and after_create/after_save hooks.
Thanks,
Jeremy
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.