Curtis,

Good idea.  The problem is with the connection pool.  The old connection 
was returned from the pool after the db had been switched.  Somehow the 
old connection was remembering the data from the old database.  My 
solution to the problem (after much digging) was to wipe out all 
connections in the pool for this db right after the swap is made.

DataObjects::Connection.new("sqlite3:///tmp/dm.db").instance_variable_get('@__pool').dispose

Not pretty, but it works.  If any one knows of a cleaner way to do the 
above, please let me know.

Your method works under a similar principal.  Since the pools are 
defined per-url, adding the rand as a parameter causes DO to use a 
completely different pool.  Is the old pool eventually cleaned up or 
does it stick around forever?  If the latter is the case, it would be a 
memory leak.  If not, your method is definitely more compact.

Earle

Curtis Summers wrote:
> It looks like DM is keeping the original connection if its setup 
> parameters are the same.  You could timestamp your db's filename, or 
> here's a hack work-around for the second call to setup:
> 
> DataMapper.setup(:default, "sqlite3:///tmp/dm.db?#{rand}")
> 
> --Curtis
> 
> On Thu, Dec 18, 2008 at 7:40 AM, Earle Clubb <[email protected] 
> <mailto:[email protected]>> wrote:
> 
> 
>     That doesn't work.  I tried re-setting up and got the same results.
>     Here's the new code I tried: http://pastie.org/342259
> 
>     Earle
> 
>     Michael Klishin wrote:
>      >
>      > On 18.12.2008, at 0:34, Earle Clubb wrote:
>      >
>      >> Is there a way to reset DM's connection to the db?
>      >
>      >
>      > Just call setup method one more time with the same repository name.
>      >
>      > MK
>      >
> 

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"DataMapper" 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/datamapper?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to