Old version availability?

13 views
Skip to first unread message

cbu...@innova-partners.com

unread,
Jun 19, 2009, 2:09:37 PM6/19/09
to Rails SQLServer Adapter
We have an app written around activerecord-sqlserver-adapter
1.0.0.9250 and this app simply won't work with the 2.2.1x versions
which are available currently. Is there an archive or access to older
versions' source code some place? I am trying to avoid a rewrite of
this app. Thanks!

Ken Collins

unread,
Jun 19, 2009, 2:12:51 PM6/19/09
to rails-sqlse...@googlegroups.com

Sure... I'm sure you can grab the 1.2.6 adapter from the rails source
code. The git repo should go all the way back to the beginning of
rails itself. My understanding is the 1.2.6 adapter was the last time
it was supported by rails. This adapter is currently tested with SQL
Server 2000 to 2008 with rails versions 2.2.x and 2.3.x.

Curious, what rails version is your app at and what changed all of a
sudden that made it either not work with the adapter you had?

- Ken

Ken Collins

unread,
Jun 19, 2009, 2:13:56 PM6/19/09
to rails-sqlse...@googlegroups.com

BTW, I never really understood what adapter was on
gems.rubyonrails.org either, but from my understanding there, they
were going to take that down since it was so far behind rails 2.x
support.

- Ken

On Jun 19, 2009, at 2:09 PM, cbu...@innova-partners.com wrote:

>

Ken Collins

unread,
Jun 19, 2009, 2:17:52 PM6/19/09
to rails-sqlse...@googlegroups.com

Sure... I'm sure you can grab the 1.2.6 adapter from the rails source
code. The git repo should go all the way back to the beginning of
rails itself. My understanding is the 1.2.6 adapter was the last time
it was supported by rails. This adapter is currently tested with SQL
Server 2000 to 2008 with rails versions 2.2.x and 2.3.x.

Curious, what rails version is your app at and what changed all of a
sudden that made it either not work with the adapter you had?

- Ken

On Jun 19, 2009, at 2:09 PM, cbu...@innova-partners.com wrote:

>

Innova

unread,
Jun 19, 2009, 2:19:33 PM6/19/09
to Rails SQLServer Adapter
I apologize for my ignorance, but do you have a link to this?

As for what changed... the server. We had to move hosting and the new
server doesn't have this gem installed. It is ruby 1.8.5.

On Jun 19, 2:12 pm, Ken Collins <k...@metaskills.net> wrote:
> Sure... I'm sure you can grab the 1.2.6 adapter from the rails source  
> code. The git repo should go all the way back to the beginning of  
> rails itself. My understanding is the 1.2.6 adapter was the last time  
> it was supported by rails. This adapter is currently tested with SQL  
> Server 2000 to 2008 with rails versions 2.2.x and 2.3.x.
>
> Curious, what rails version is your app at and what changed all of a  
> sudden that made it either not work with the adapter you had?
>
>   - Ken
>

Ken Collins

unread,
Jun 19, 2009, 2:22:38 PM6/19/09
to rails-sqlse...@googlegroups.com

What "RAILS" version? Not ruby. Rails. I was just curious if it was
1.2.6 or the fuzzy middle ground to 2.2 which I started writing the
adapter for. I'm curious too how you know the current adapter does not
work for it?

As far as where to get rails source code
http://github.com/rails/rails

You can either clone the repo or just use the handy download links. :)
http://github.com/rails/rails/downloads

Innova

unread,
Jun 19, 2009, 2:28:00 PM6/19/09
to Rails SQLServer Adapter
Sorry, it is Rails 2.3.2. I am just the server admin doing what the
devs are telling me, so I will have to defer to them as how they know
it doesn;t work. i am getting decriptive responses like "It gives me
funky errors". Let me get the dev involved here and he can tell you
much more.

On Jun 19, 2:22 pm, Ken Collins <k...@metaskills.net> wrote:
> What "RAILS" version? Not ruby. Rails. I was just curious if it was  
> 1.2.6 or the fuzzy middle ground to 2.2 which I started writing the  
> adapter for. I'm curious too how you know the current adapter does not  
> work for it?
>
> As far as where to get rails source codehttp://github.com/rails/rails
>
> You can either clone the repo or just use the handy download links. :)http://github.com/rails/rails/downloads

Ken Collins

unread,
Jun 19, 2009, 2:31:52 PM6/19/09
to rails-sqlse...@googlegroups.com

They really should use the current adapter. IT PASSES ALL THE TESTS! I
mean really. The old adapter is failing more than half the tests.
Sounds to me that perhaps the app is monkey patched in bad way and
nobody knows how anymore :)

Do what works best for you, but I'd use the tested/supported adapter
anytime :)


- Ken

Ken Collins

unread,
Jun 19, 2009, 2:33:36 PM6/19/09
to rails-sqlse...@googlegroups.com

You could even copy the gem from the old server and package it in the
apps vendor dir too.

- Ken

Jon Canady

unread,
Jun 19, 2009, 2:40:06 PM6/19/09
to Rails SQLServer Adapter
Ken,

Passing the tests is all well and good, but we're getting the
following error on 2.2.19, when 1.0.0.9250 worked fine. We have a
handful of ActiveRecord models, none more complicated than a couple of
has_many/belongs_to associations. They're five or so lines. I'm not
deliberately monkey-patching anything myself, and the one ActiveRecord
plugin (default_value_for) we were using was disabled to no effect.

The following dump is for 2.2.18, but .19 does the exact same thing.

/usr/lib/ruby/gems/1.8/gems/activerecord-sqlserver-adapter-2.2.18/lib/
active_record/connection_adapters/sqlserver_adapter.rb:1084:in
`column_definitions': undefined method `[]' for nil:NilClass
(NoMethodError) from /usr/lib/ruby/gems/1.8/gems/activerecord-
sqlserver-adapter-2.2.18/lib/active_record/connection_adapters/
sqlserver_adapter.rb:1062:in `collect' from /usr/lib/ruby/gems/
1.8/gems/activerecord-sqlserver-adapter-2.2.18/lib/active_record/
connection_adapters/sqlserver_adapter.rb:1062:in
`column_definitions' from /usr/lib/ruby/gems/1.8/gems/
activerecord-sqlserver-adapter-2.2.18/lib/active_record/
connection_adapters/sqlserver_adapter.rb:618:in `columns'
from /usr/lib/ruby/gems/1.8/gems/activerecord-sqlserver-
adapter-2.2.18/lib/active_record/connection_adapters/
sqlserver_adapter.rb:1109:in `special_columns'
from /usr/lib/ruby/gems/1.8/gems/activerecord-sqlserver-
adapter-2.2.18/lib/active_record/connection_adapters/
sqlserver_adapter.rb:1113:in `repair_special_columns'
from /usr/lib/ruby/gems/1.8/gems/activerecord-sqlserver-
adapter-2.2.18/lib/active_record/connection_adapters/
sqlserver_adapter.rb:815:in `select'
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/
active_record/connection_adapters/abstract/database_statements.rb:7:in
`select_all_without_query_cache'
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/
active_record/connection_adapters/abstract/query_cache.rb:62:in
`select_all'
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/
active_record/base.rb:661:in `find_by_sql'
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/
active_record/base.rb:1553:in `find_every'
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/
active_record/base.rb:615:in `find'
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/
active_record/base.rb:635:in `all'
from ./script.rb:6

--Jon

Ken Collins

unread,
Jun 19, 2009, 3:41:13 PM6/19/09
to rails-sqlse...@googlegroups.com

If you would like help, I'd have to see more of a stack trace.... IE,
the model that called that all method would be the culprit. Perhaps
it's set table name? Perhaps even your ODBC and/or DBI needs to be
updated? Are you running the recommended versions?

This looks like a simple issue.


- Ken

Ken Collins

unread,
Jun 19, 2009, 3:45:39 PM6/19/09
to rails-sqlse...@googlegroups.com

BTW, this adapter has a setting that I sometimes use in an initializer
for #log_info_schema_queries. You can see more in the readme where
these typically go in your setup. If that was set to true, you would
see the SQL generated for the column definitions right before the
failure.

- Ken

On Jun 19, 2009, at 2:40 PM, Jon Canady wrote:

>

Jon Canady

unread,
Jun 19, 2009, 4:18:40 PM6/19/09
to Rails SQLServer Adapter
All of the required libraries are the recommended latest versions (dbi
0.4.1, dbd-odbc 0.2.4). We turned on the INFORMATION_SCHEMA logging,
which appears below. The three queries that run up to the NilClass
exception return results when executed through SQL Server client
tools, and if I remember right our trace indicated all three queries
hit the database and returned results.

The model appears below, followed by the output of the script.


class Account < ActiveRecord::Base
set_table_name 'T_LeadVendorAccount'
set_primary_key 'LeadVendorAccountID'

has_many :emails, :foreign_key => 'LeadVendorAccountID'
end

SQL (2.2ms) SELECT @@version
SQL (80.5ms) SELECT columns.TABLE_NAME as table_name,
columns.COLUMN_NAME as name, columns.DATA_TYPE as type,
columns.COLUMN_DEFAULT as default_value, columns.NUMERIC_SCALE as
numeric_scale, columns.NUMERIC_PRECISION as numeric_precision, CASE
WHEN columns.DATA_TYPE IN ('nchar','nvarchar') THEN
columns.CHARACTER_MAXIMUM_LENGTH ELSE COL_LENGTH(columns.TABLE_NAME,
columns.COLUMN_NAME) END as length, CASE WHEN columns.IS_NULLABLE =
'YES' THEN 1 ELSE NULL end as is_nullable, CASE WHEN COLUMNPROPERTY
(OBJECT_ID(columns.TABLE_NAME), columns.COLUMN_NAME, 'IsIdentity') = 0
THEN NULL ELSE 1 END as is_identity FROM INFORMATION_SCHEMA.COLUMNS
columns WHERE columns.TABLE_NAME = 'T_LeadVendorAccount' ORDER BY
columns.ordinal_position
SQL (172.8ms) SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS
WHERE TABLE_NAME NOT IN ('sysconstraints','syssegments')
/usr/lib/ruby/gems/1.8/gems/rails-sqlserver-2000-2005-adapter-2.2.19/
lib/active_record/connection_adapters/sqlserver_adapter.rb:1084:in
`column_definitions': undefined method `[]' for nil:NilClass
(NoMethodError)
from /usr/lib/ruby/gems/1.8/gems/rails-sqlserver-2000-2005-
adapter-2.2.19/lib/active_record/connection_adapters/
sqlserver_adapter.rb:1062:in `collect'
from /usr/lib/ruby/gems/1.8/gems/rails-sqlserver-2000-2005-
adapter-2.2.19/lib/active_record/connection_adapters/
sqlserver_adapter.rb:1062:in `column_definitions'
from /usr/lib/ruby/gems/1.8/gems/rails-sqlserver-2000-2005-
adapter-2.2.19/lib/active_record/connection_adapters/
sqlserver_adapter.rb:618:in `columns'
from /usr/lib/ruby/gems/1.8/gems/rails-sqlserver-2000-2005-
adapter-2.2.19/lib/active_record/connection_adapters/
sqlserver_adapter.rb:1109:in `special_columns'
from /usr/lib/ruby/gems/1.8/gems/rails-sqlserver-2000-2005-
adapter-2.2.19/lib/active_record/connection_adapters/
sqlserver_adapter.rb:1113:in `repair_special_columns'
from /usr/lib/ruby/gems/1.8/gems/rails-sqlserver-2000-2005-
adapter-2.2.19/lib/active_record/connection_adapters/
sqlserver_adapter.rb:815:in `select'
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/
active_record/connection_adapters/abstract/database_statements.rb:7:in
`select_all_without_query_cache'
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/
active_record/connection_adapters/abstract/query_cache.rb:62:in
`select_all'
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/
active_record/base.rb:661:in `find_by_sql'
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/
active_record/base.rb:1553:in `find_every'
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/
active_record/base.rb:615:in `find'
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/
active_record/base.rb:635:in `all'
from ./parse_mail.rb:6


--Jon

Ken Collins

unread,
Jun 19, 2009, 4:59:04 PM6/19/09
to rails-sqlse...@googlegroups.com

This relates to a specific schema thing on your end, and I'd like to
know what. Basically it is bombing at find a default value at the
regex line here:

ci[:default_value].match(/\A\(+N?'?(.*?)'?\)+\Z/)[1]

I've had issues with this before and as we have developed that regex I
have had to put a few debug statements in there to see what value is
in the default value. You can add an "logger.debug
ci[:default_value].inspect" and see what is there. Perhaps you have a
function in there as the default value?


- Ken

Jon Canady

unread,
Jun 19, 2009, 5:48:02 PM6/19/09
to Rails SQLServer Adapter
Aha!

Interestingly, we have the string "dbo.System" as the default value on
those columns. I've seen instances where ActiveRecord parses these
out as Schema.Object statements as opposed to just a string. Could
this have some relevance?

Putting the debug print on line 1090 (right before the case statement)
yeilds the following output immediately before the stack trace:


nil
nil
nil
nil
nil
"((-1))"
"create default [CurrentDateTime] as getdate()"


--Jon
> ...
>
> read more »

Ken Collins

unread,
Jun 19, 2009, 7:21:03 PM6/19/09
to rails-sqlse...@googlegroups.com

Could you create a ticket on the Github issue page? I would label the
issue relating to default functions for column values. If you wanted
to fix this locally, perhaps just try adding a "rescue nil" at the end
of that line. I think in our case, we found that this default value
was actually a SQL Server bug in some old legacy schema statements
from Erwin. Hence the adapter was never made to work around it was
because we felt that people would want to know when things were in
their DB that were bad.

If any of my assumptions are wrong, details can be provided in the
ticket.


- Ken

Jon Canady

unread,
Jun 20, 2009, 4:29:43 PM6/20/09
to Rails SQLServer Adapter
Yeah, rescue nil fixed the issue locally. I don't know why I didn't
think to toss that in there, but when deadlines are looming you don't
think straight. I'll create the ticket later today.

--Jon
> ...
>
> read more »
Reply all
Reply to author
Forward
0 new messages