Skip to content

Default Functions for Column Values #8

@jesscanady

Description

@jesscanady

Re: this thread on the list.

When attempting to connect to a SQL Server instance using v2.2.19, the adapter would bomb out with a stack trace along the lines of:

/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 

This seems to be related to the following line:

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

When we add print out ci[:default_value].inspect on line 1090 of sqlserver_adapter.rb we get the following output right before the stack trace:

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

Now, adding a rescue nil suffix to the :default_value regex line catches the NilClass error and fixes it locally for us, but doesn't seem sustainable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions