rails-sqlserver/activerecord-sqlserver-adapter — Issue #173: Tries to connect to Mysql instead of SQL Server
Author: ivanoats
Created: 2012-03-09 23:34:06+00:00
State: open

I don't know if this is an issue with the adapter or my code but I could definitely use some help if available.

Here's my db config:
```
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: c4c_development
pool: 5
username: root
password:
host: localhost

ipp_v5:
adapter: sqlserver
host: host_name.washington.edu
database: database_name
username: somewhat_secret
password: super_secret
```

Here's my class:
```
class BDP < ActiveRecord::Base

establish_connection Rails.configuration.database_configuration["ipp_v5"]

self.table_name = "Campaign"
self.primary_key = "CAMPAIGNKEYGUID"
alias_attribute "id", "CAMPAIGNKEYGUID"

before_create :set_guid_column

def set_guid_column
self[:CAMPAIGNKEYGUID] ||= connection.newid_function
end

has_many :projects

end
```

BDP.find(:first) works.

```
1.9.3p125 :002 > BDP.offset(2)
ActiveRecord::StatementInvalid: Mysql2::Error: Table 'c4c_development.campaign' doesn't exist: SHOW CREATE TABLE `Campaign`
from /Users/ivan/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:243:in `query'
from /Users/ivan/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:243:in `block in execute'
from /Users/ivan/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract_adapter.rb:280:in `block in log'
from /Users/ivan/.rvm/gems/ruby-1.9.3-p125/gems/activesupport-3.2.2/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
from /Users/ivan/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log'
from /Users/ivan/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:243:in `execute'
from /Users/ivan/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.2.2/lib/active_record/connection_adapters/mysql2_adapter.rb:211:in `execute'
from /Users/ivan/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:257:in `execute_and_free'
from /Users/ivan/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:515:in `pk_and_sequence_for'
from /Users/ivan/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:528:in `primary_key'
from /Users/ivan/.rvm/gems/ruby-1.9.3-p125/gems/arel-3.0.2/lib/arel/table.rb:40:in `primary_key'
from /Users/ivan/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-sqlserver-adapter-3.2.1/lib/arel/visitors/sqlserver.rb:367:in `rowtable_orders'
from /Users/ivan/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-sqlserver-adapter-3.2.1/lib/arel/visitors/sqlserver.rb:170:in `visit_Arel_Nodes_SelectStatementWithOffset'
from /Users/ivan/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-sqlserver-adapter-3.2.1/lib/arel/visitors/sqlserver.rb:97:in `visit_Arel_Nodes_SelectStatement'
from /Users/ivan/.rvm/gems/ruby-1.9.3-p125/gems/arel-3.0.2/lib/arel/visitors/visitor.rb:19:in `visit'
from /Users/ivan/.rvm/gems/ruby-1.9.3-p125/gems/arel-3.0.2/lib/arel/visitors/visitor.rb:5:in `accept'
... 1 levels...
from /Users/ivan/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in `to_sql'
from /Users/ivan/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract/database_statements.rb:18:in `select_all'
from /Users/ivan/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract/query_cache.rb:63:in `select_all'
from /Users/ivan/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.2.2/lib/active_record/querying.rb:38:in `block in find_by_sql'
from /Users/ivan/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.2.2/lib/active_record/explain.rb:40:in `logging_query_plan'
from /Users/ivan/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.2.2/lib/active_record/querying.rb:37:in `find_by_sql'
from /Users/ivan/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.2.2/lib/active_record/relation.rb:171:in `exec_queries'
from /Users/ivan/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.2.2/lib/active_record/relation.rb:160:in `block in to_a'
from /Users/ivan/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.2.2/lib/active_record/explain.rb:40:in `logging_query_plan'
from /Users/ivan/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.2.2/lib/active_record/relation.rb:159:in `to_a'
from /Users/ivan/.rvm/gems/ruby-1.9.3-p125/gems/activerecord-3.2.2/lib/active_record/relation.rb:496:in `inspect'
from /Users/ivan/.rvm/gems/ruby-1.9.3-p125/gems/railties-3.2.2/lib/rails/commands/console.rb:47:in `start'
from /Users/ivan/.rvm/gems/ruby-1.9.3-p125/gems/railties-3.2.2/lib/rails/commands/console.rb:8:in `start'
from /Users/ivan/.rvm/gems/ruby-1.9.3-p125/gems/railties-3.2.2/lib/rails/commands.rb:41:in `'
from script/rails:6:in `require'
from script/rails:6:in `

'1.9.3p125 :003
```