cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with activerecord-sqlanywhere-adapter

Former Member
0 Kudos
1,980

It seems as if there is a bug in the arel code of the adapter. Calling "Model.first" generates the following error:

ActiveRecord::StatementInvalid: ActiveRecord::ConnectionAdapters::SQLAnywhereException: Syntax error near '<' on line 1: SELECT TOP #<arel::nodes::limit:0x00000102a0bbf0> "mi_def".* FROM "mi_def"

You can get around it by calling "Model.first(1)", but that doesn't help when you have associations. Trying to access an associated model generates the same error.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member

I fixed it myself by changing the following line in activerecord-sqlanywhere-adapter/lib/arel/visitors/sqlanywhere.rb

("TOP #{o.limit}" if o.limit),

to

(visit(Nodes::Top.new(o.limit.expr)) if o.limit),

I will try to submit a patch when I get a chance.

Former Member
0 Kudos

On second thought, maybe not. The git project is read-only. Any idea on how to submit patches?

Former Member
0 Kudos

Thank you for fixing this. Please create a git patch, and email it to sqlany_interfaces@sybase.com.

Thanks.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

this still appears to be broken. Why wasn't the gem updated? Is there a problem with this patch?

On another note when can we expect Rails 3.1 support?