On Monday, February 1, 2016 at 12:45:16 PM UTC-8, Jeremy Swartwood wrote: > > The following seems to work, but reading some other threads I'm confused > why, as they had to alter how transaction worked, or pass in server: > :my_server. > > I just want to make sure that using with_server followed by a transaction > block, will mean the transaction AND all the model > create/save/update/delete calls run against the server specified in the > with_server block. > > model_object.db.with_server(:write_access) do > model_object.db.transaction( rollback: :reraise) do > > > end > > end > > > > This seems to work. All the creates within the block happen against the > :write_access server, and if one of them fails, a rollback happens. > > Now, if I create 2 separate connections instead of the sharding mechanism, > naming them reader_db and writer_db. This would not rollback. > > Was this fixed since this article? > https://groups.google.com/forum/#!topic/sequel-talk/aXrOnezRJ9s > > *In that article you instructed the person to use:* > def DB.transaction(opts={}, &block) > super{with_server(opts[:server], &block)} > end > > *In this article, the person just passes server => :server_symbol_name:* > > https://groups.google.com/forum/#!searchin/sequel-talk/transaction/sequel-talk/FXPE3RGXVIw/KNud26tCAAAJ > DB.transaction( :server => :testserver ) >
What you are describing is basically two ways to do the same thing. You can be explicit and call with_server around every call to transaction, or you can have it handled implicitly by overriding the transaction method and calling super. In short, what you have should work correctly. If you are having problems with it, please post details and we'll try to troubleshoot. 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 https://groups.google.com/group/sequel-talk. For more options, visit https://groups.google.com/d/optout.
