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.

asked 25 Apr '11, 23:35

Anth's gravatar image

Anth
16226
accept rate: 100%

edited 26 Apr '11, 13:50


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.

permanent link

answered 26 Apr '11, 00:31

Anth's gravatar image

Anth
16226
accept rate: 100%

edited 26 Apr '11, 00:50

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

(26 Apr '11, 00:51) Anth

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

Thanks.

(28 Apr '11, 11:46) Eric Farrar

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?

permanent link

answered 11 Nov '11, 12:05

clst's gravatar image

clst
16115
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×85

question asked: 25 Apr '11, 23:35

question was seen: 900 times

last updated: 11 Nov '11, 12:05