On Jun 4, 3:00 pm, John Firebaugh <[email protected]> wrote: > IMO, when Sequel.connect is passed a block, the resulting database should > not be pushed onto Sequel::DATABASES. That opens the possibility that some > other thread will come in while the block is executing and wind up using the > database, which is almost certainly a mistake (which I was just bitten by). > > This would break any code currently relying on retrieving the database from > DATABASES from within the block, but such code is suspect anyway -- it would > be better off using the block parameter instead, to be sure of using the > right database.
Removing it would break code that creates Sequel::Model classes inside the block. I'm not sure if such usage is suspect, but you are correct that it can be worked around by specifying the database when creating the model classes. However, I'm not sure if breaking backwards compatibility is worth it in this case. Can you describe in more detail your situation and why this caused a problem? > (Is the use of Sequel::DATABASES even threadsafe? Unless Array#push and > #delete are guaranteed to be atomic, it appears not.) I believe Array#push and Array#delete are atomic/threadsafe in MRI, as they are implemented in C. That may not be true on JRuby, though. Jeremy -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. 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.
