Syntax error with sqlserver adapter and octopus

46 views
Skip to first unread message

lanej

unread,
Apr 2, 2011, 2:22:40 PM4/2/11
to Rails SQLServer Adapter
I am trying to use tiny tds and sqlserver adapter on a shared mssql
database. I'm using octopus to manage the sharding

The problem I am having is this :

ruby-1.9.2-p180 :009 > Octopus.using(:pg2){Comment.first}
ActiveRecord::StatementInvalid: TinyTds::Error: Incorrect syntax near
'1'.: SELECT [ISBizBlogger_Comment].* FROM [ISBizBlogger_Comment]
LIMIT 1

shards.yml:
octopus:
environments:
- test
- development
- qa
qa:
portal_groups:
pg2:
dataserver: qahost
username: qausername
password: qapassword
mode: dblib
port: 1433
development:
portal_groups:
pg1:
host: localhost
adapter: mysql2
database: judge_dev_shard_1
username: root
password: root
pg2:
host: localhost
adapter: mysql2
database: judge_dev_shard_2
username: root
password: root
test:
portal_groups:
pg1:
host: localhost
adapter: mysql2
database: judge_test_shard_1
username: root
password: root
pg2:
host: localhost
adapter: mysql2
database: judge_test_shard_2
username: root
password: root

config/database.yml
development:
adapter: mysql2
host: localhost
database: judge_development
username: root
password: root
pool: 5
timeout: 5000

qa:
host: qa.reference.com
username: username
password: password
adapter: mysql2
database: QA
pool: 5
timeout: 5000

test:
adapter: mysql2
host: localhost
database: judge_test
username: root
password: root
pool: 5
timeout: 5000


/etc/freetds/freetds.conf
[global]

tds version = 8.0
connect timeout = 10
text size = 64512
port = 1433

# dump file = /tmp/freetds.log
# debug flags = 0xffff
# timeout = 10


[qahost]
host = qahost

Gemfile
source 'http://rubygems.org'

gem 'rails', '3.0.5'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'sqlite3'
gem "mysql2"
gem "ar-octopus", :require => "octopus", :git => "https://github.com/
tchandy/octopus.git"
gem "haml"

group :qa do
gem "tiny_tds"
gem "activerecord-sqlserver-adapter", :require => false
end

app/models/comment.rb
class Comment < ActiveRecord::Base
octopus_set_table_name "ISBizBlogger_Comment"

end

Ken Collins

unread,
Apr 2, 2011, 3:16:22 PM4/2/11
to rails-sqlse...@googlegroups.com

The SQL being generated is for MySQL. There are some wires cross somewhere and it is likely either you own config or an Octopus issue. Not knowing anything about Octopus, I do not see anything in shards.yml that denotes :pg2 as being anything specific to the adapter for SQL Server, which would correctly load the correct sql visitor and generate the correct SQL.

- Ken

> --
> You received this message because you are subscribed to the Google Groups "Rails SQLServer Adapter" group.
> To post to this group, send email to rails-sqlse...@googlegroups.com.
> To unsubscribe from this group, send email to rails-sqlserver-a...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/rails-sqlserver-adapter?hl=en.
>

Erik Bryn

unread,
Apr 2, 2011, 4:05:38 PM4/2/11
to rails-sqlse...@googlegroups.com
Maybe try specifying "adapter: sqlserver" in the pg2 definition?

- Erik

lanej

unread,
Apr 4, 2011, 10:07:54 AM4/4/11
to Rails SQLServer Adapter
my apologies, i posted an out of date version of the shards.yml.
updated version is below.

I agree that this bug seems likely to be an octopus issue, any
feedback would be appreciated, I will reference this thread in the
octopus discussion.

octopus:
environments:
- test
- development
- qa
qa:
portal_groups:
pg2:
database: pg2
username: username
password: password
adapter: sqlserver
dataserver: pg2.server.com
> >> For more options, visit this group athttp://groups.google.com/group/rails-sqlserver-adapter?hl=en.
Reply all
Reply to author
Forward
0 new messages