Good points. Makes sense. Will do!

Ed

On Tuesday, March 5, 2013 11:23:35 AM UTC-8, Jeremy Evans wrote:
>
> On Tuesday, March 5, 2013 10:52:52 AM UTC-8, Ed Ruder wrote:
>>
>> When Sequel connects to the database is not an implementation detail 
>> because it has side effects.
>>
>
> Plenty of things that are implementation details have side effects.  Just 
> because something is an implementation detail does not mean it has no side 
> effects.
>  
>
>> For example, we're using Sequel in a small Rails app. We're setting up 
>> the connection_validator in an initializer, so that it's configured for the 
>> life of the app. We also have Rake tasks that drop the database, create it, 
>> and apply migrations to it. This task happens to need to load the Rails 
>> environment before running, so the connection_validator is set up. But the 
>> drop of the database fails, because of the database connection that is 
>> outstanding:
>>
>> dropdb: database removal failed: ERROR:  database "bbox_test" is being 
>> accessed by other users
>> DETAIL:  There are 1 other session(s) using the database.
>>
>>
>> We can have code run differently (e.g., not depend on the Rails 
>> environment), but because we have to change around our code to work 
>> properly, I think it's incorrect to say that "The point at which Sequel 
>> makes a connection is an implementation detail". For reasons like ours, when 
>> Sequel makes a connection needs to be well-documented and predictable, *so 
>> that* clients can write their code properly.
>>
>>
> Any time you want to drop a database you have connected to, you should be 
> running Database#disconnect first.  That's true regardless of whether you 
> use the connection_validator extension or not.  The fact that your code 
> worked before you used the connection_validator extension was just luck.  
> For example, if you had loaded a model class or run any queries in your 
> initializer, you would have had the same error.
>
> 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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to