datamapper/do — Issue #20: DataObjects error when using two repositories
Author: jvalencia80
Created: 2012-01-04 09:56:46+00:00
State: open

I have this simple code using two sqlite stores:

```ruby
require "data_mapper"

class Foo
include DataMapper::Resource

property :id, Serial
property :name, String
end

DataMapper.finalize

DataMapper.setup(:default, "sqlite:foo.sqlite")
DataMapper.setup(:lite, "sqlite:foo2.sqlite")

DataMapper.repository(:default).auto_migrate!
DataMapper.repository(:lite).auto_migrate!

# :default repo
Foo.create(:name => "foo")

# :lite repo
DataMapper.repository(:lite) { Foo.create(:name => "bar") }
```

Default repository works, but Lite repository throws this error:

/usr/lib/ruby/gems/1.9.1/gems/dm-do-adapter-1.2.0/lib/dm-do-adapter/adapter.rb:114:in `execute_non_query': no such table: foos (DataObjects::SyntaxError)
from /usr/lib/ruby/gems/1.9.1/gems/dm-do-adapter-1.2.0/lib/dm-do-adapter/adapter.rb:114:in `block (2 levels) in create'
from /usr/lib/ruby/gems/1.9.1/gems/dm-do-adapter-1.2.0/lib/dm-do-adapter/adapter.rb:276:in `with_connection'
from /usr/lib/ruby/gems/1.9.1/gems/dm-do-adapter-1.2.0/lib/dm-do-adapter/adapter.rb:113:in `block in create'
from /usr/lib/ruby/gems/1.9.1/gems/dm-do-adapter-1.2.0/lib/dm-do-adapter/adapter.rb:85:in `each'
from /usr/lib/ruby/gems/1.9.1/gems/dm-do-adapter-1.2.0/lib/dm-do-adapter/adapter.rb:85:in `create'
from /usr/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core/repository.rb:146:in `create'
from /usr/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core/resource/persistence_state/transient.rb:61:in `create_resource'
from /usr/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core/resource/persistence_state/transient.rb:25:in `commit'
from /usr/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core/resource.rb:956:in `_persist'
from /usr/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core/resource.rb:970:in `block in create_with_hooks'
from /usr/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core/resource.rb:967:in `catch'
from /usr/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core/resource.rb:967:in `create_with_hooks'
from /usr/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core/resource.rb:1021:in `save_self'
from /usr/lib/ruby/gems/1.9.1/gems/dm-validations-1.2.0/lib/dm-validations.rb:54:in `save_self'
from /usr/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core/resource.rb:1006:in `block in _save'
from /usr/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core/resource.rb:1222:in `run_once'
from /usr/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core/resource.rb:1005:in `_save'
from /usr/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core/resource.rb:405:in `save'
from /usr/lib/ruby/gems/1.9.1/gems/dm-validations-1.2.0/lib/dm-validations.rb:40:in `block in save'
from /usr/lib/ruby/gems/1.9.1/gems/dm-validations-1.2.0/lib/dm-validations/context.rb:16:in `in_context'
from /usr/lib/ruby/gems/1.9.1/gems/dm-validations-1.2.0/lib/dm-validations.rb:40:in `save'
from /usr/lib/ruby/gems/1.9.1/gems/dm-validations-1.2.0/lib/dm-validations.rb:130:in `create'
from foo.rb:22:in `block in

'
from /usr/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core.rb:263:in `block in repository'
from /usr/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core/repository.rb:114:in `scope'
from /usr/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core.rb:263:in `repository'
from foo.rb:22:in `

'

Is this a bug?

I'm using recently updated gems:

data_objects (0.10.7)
datamapper (1.2.0)
dm-aggregates (1.2.0)
dm-constraints (1.2.0)
dm-core (1.2.0)
dm-do-adapter (1.2.0)
dm-migrations (1.2.0)
dm-mysql-adapter (1.2.0)
dm-serializer (1.2.1)
dm-sqlite-adapter (1.2.0)
dm-timestamps (1.2.0)
dm-transactions (1.2.0)
dm-types (1.2.1)
dm-validations (1.2.0)
do_mysql (0.10.7)
do_sqlite3 (0.10.7)

and my ruby version:

ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]