datamapper / do

DataObjects
147 stars 73 forks source link

DataObjects::ConnectionError when loading both dm-mysql-adapter and dm-sqlite-adapter gems #11

Closed ahto closed 13 years ago

ahto commented 13 years ago

dkubb asked to make this ticket on irc and of course I didn't read that he wanted it to github, not lighthouse. Sorry about the duplicate http://datamapper.lighthouseapp.com/projects/20609-datamapper/tickets/1512-dataobjectsconnectionerror-when-loading-both-dm-mysql-adapter-and-dm-sqlite-adapter-gems

I have in my Gemfile both dm-mysql-adapter and dm-sqlite-adapter. First for prod/dev and sqlite for speedy tests. I load them using bundler and now when I run tests even though I specifically setup with DataMapper.setup(:default, "sqlite::memory:") it tries to connect somewhere else using some default rules with root@localhost. My code runs after I comment out the dm-mysql from Gemfile.

Gemfile has

gem 'datamapper', '1.1.0'
gem 'dm-mysql-adapter', '1.1.0'
gem 'dm-sqlite-adapter', '1.1.0'

I setup them with

Bundler.setup
DataMapper.setup(:default, "sqlite::memory:")

Expected behaviour

Datamapper would connect to in memory sqlite database

What really happens

DataObjects::ConnectionError: Access denied for user 'root'@'localhost' (using password: NO)

Backtrace

DataObjects::ConnectionError: Access denied for user 'root'@'localhost' (using password: NO)
/home/ahto/.rvm/gems/ruby-1.9.2-p180@ultra/gems/data_objects-0.10.5/lib/data_objects/connection.rb:79:in `initialize'
/home/ahto/.rvm/gems/ruby-1.9.2-p180@ultra/gems/data_objects-0.10.5/lib/data_objects/connection.rb:79:in `new'
/home/ahto/.rvm/gems/ruby-1.9.2-p180@ultra/gems/data_objects-0.10.5/lib/data_objects/pooling.rb:177:in `block in new'
<internal:prelude>:10:in `synchronize'
/home/ahto/.rvm/gems/ruby-1.9.2-p180@ultra/gems/data_objects-0.10.5/lib/data_objects/pooling.rb:172:in `new'
/home/ahto/.rvm/gems/ruby-1.9.2-p180@ultra/gems/data_objects-0.10.5/lib/data_objects/pooling.rb:119:in `new'
/home/ahto/.rvm/gems/ruby-1.9.2-p180@ultra/gems/data_objects-0.10.5/lib/data_objects/connection.rb:68:in `new'
/home/ahto/.rvm/gems/ruby-1.9.2-p180@ultra/gems/dm-do-adapter-1.1.0/lib/dm-do-adapter/adapter.rb:251:in `open_connection'
/home/ahto/.rvm/gems/ruby-1.9.2-p180@ultra/gems/dm-transactions-1.1.0/lib/dm-transactions/adapters/dm-do-adapter.rb:69:in `open_connection'
/home/ahto/.rvm/gems/ruby-1.9.2-p180@ultra/gems/dm-do-adapter-1.1.0/lib/dm-do-adapter/adapter.rb:276:in `with_connection'
/home/ahto/.rvm/gems/ruby-1.9.2-p180@ultra/gems/dm-do-adapter-1.1.0/lib/dm-do-adapter/adapter.rb:33:in `select'
/home/ahto/.rvm/gems/ruby-1.9.2-p180@ultra/gems/dm-migrations-1.1.0/lib/dm-migrations/adapters/dm-sqlite-adapter.rb:43:in `table_info'
/home/ahto/.rvm/gems/ruby-1.9.2-p180@ultra/gems/dm-migrations-1.1.0/lib/dm-migrations/adapters/dm-sqlite-adapter.rb:18:in `storage_exists?'
/home/ahto/.rvm/gems/ruby-1.9.2-p180@ultra/gems/dm-migrations-1.1.0/lib/dm-migrations/auto_migration.rb:63:in `storage_exists?'
/home/ahto/.rvm/gems/ruby-1.9.2-p180@ultra/gems/dm-migrations-1.1.0/lib/dm-migrations/auto_migration.rb:118:in `storage_exists?'
/home/ahto/.rvm/gems/ruby-1.9.2-p180@ultra/gems/dm-constraints-1.1.0/lib/dm-constraints/migrations.rb:36:in `auto_migrate_down_constraints!'
/home/ahto/.rvm/gems/ruby-1.9.2-p180@ultra/gems/dm-migrations-1.1.0/lib/dm-migrations/auto_migration.rb:45:in `block in repository_execute'
/home/ahto/.rvm/gems/ruby-1.9.2-p180@ultra/gems/dm-core-1.1.0/lib/dm-core/support/descendant_set.rb:66:in `block in each'
/home/ahto/.rvm/gems/ruby-1.9.2-p180@ultra/gems/dm-core-1.1.0/lib/dm-core/support/subject_set.rb:212:in `block in each'
/home/ahto/.rvm/gems/ruby-1.9.2-p180@ultra/gems/dm-core-1.1.0/lib/dm-core/support/ordered_set.rb:321:in `block in each'
/home/ahto/.rvm/gems/ruby-1.9.2-p180@ultra/gems/dm-core-1.1.0/lib/dm-core/support/ordered_set.rb:321:in `each'
/home/ahto/.rvm/gems/ruby-1.9.2-p180@ultra/gems/dm-core-1.1.0/lib/dm-core/support/ordered_set.rb:321:in `each'
/home/ahto/.rvm/gems/ruby-1.9.2-p180@ultra/gems/dm-core-1.1.0/lib/dm-core/support/subject_set.rb:212:in `each'
/home/ahto/.rvm/gems/ruby-1.9.2-p180@ultra/gems/dm-core-1.1.0/lib/dm-core/support/descendant_set.rb:65:in `each'
/home/ahto/.rvm/gems/ruby-1.9.2-p180@ultra/gems/dm-migrations-1.1.0/lib/dm-migrations/auto_migration.rb:44:in `repository_execute'
/home/ahto/.rvm/gems/ruby-1.9.2-p180@ultra/gems/dm-constraints-1.1.0/lib/dm-constraints/migrations.rb:10:in `auto_migrate!'
spec/models/account_spec.rb:8:in `block (2 levels) in <top (required)>
dkubb commented 13 years ago

I can confirm this is a problem for me too. However, there appears to be some platform differences since @dbussink wasn't able to reproduce locally. What I propose is that we use a VirtualBox VM to test things in, since it should behave the same across all architectures. I've put together the steps to build the VM and install the software to reproduce the problem: https://gist.github.com/985183

(BTW: You will need to install VirtualBox first. The download URI is on line 2 inside the gist)

@dbussink: does this help? Is there anything else you need from me? It looks like a load order dependency issue, likely some shared state being clobbered by the gems.

solnic commented 13 years ago

This is also related to issue reported by @postmodern

dkubb commented 13 years ago

@solnic: yes, this is the same issue as #10 (or appears to be)

myabc commented 13 years ago

This should have been closed along with issue #10.