Hi,

I'm currently using the Ruby SQLA connectors (https://github.com/sqlanywhere) with Rail 3.0.7 & Ruby 1.9.2 without any problems. After upgrading to Rails 3.0.10 I'm getting the following error:

ActiveRecord::StatementInvalid (ActiveRecord::ConnectionAdapters::SQLAnywhereException: Syntax error near '<' on line 1: SELECT TOP #<arel::nodes::limit:0xbdd77cc> "sessions".* FROM "sessions" WHERE "sessions"."session_id" = '297bc97413b5d1da5c765f8b98f2c06b'):

Has anyone else struck this problem, any ideas on what the cause could be?

Regards,

Etienne.

asked 08 Sep '11, 18:30

etienne's gravatar image

etienne
31224
accept rate: 0%

It appears that the SQL text getting sent to the database server by the client really is "SELECT TOP #<arel..." and as soon as it hits that pointer information, it reports back as a syntax error.

Here's where we build up the statement in /lib/active_record/connection_adapters/sql_adapter.rb

def modify_limit_offset(sql) ... final_sql = "SELECT #{select_components[0][0]} " final_sql << "TOP #{select_components[0][2].nil? ? 1000000 : select_components[0][2]} " ...

I would guess that perhaps this function may no longer be correct for the current version of Ruby/Rails.

Can you put together a short Rails code sample that demonstrates the issue?

(13 Sep '11, 15:39) Jeff Albion

H Jeff,

Thanks for your reply it's much appreciated.

I'm away for the next few days but I'll try and get something together next week.

Regards,

Etienne.

(14 Sep '11, 19:48) etienne

Not to all, there is additional discussion on this topic going on at the activerecord-sqlanywhere-adapter github code repository: https://github.com/sqlanywhere/activerecord-sqlanywhere-adapter/issues/2

Will look into adding this support to the main adapter.

(19 Oct '11, 15:06) Eric Farrar
Replies hidden

Hi Eric,

That is really good news.

(27 Oct '11, 01:12) etienne

Hi Eric,

Have you had a chance to look at adding support for Rails 3.0.10+?

(21 Feb '12, 20:19) etienne

Hi Etienne,

Yes, we have have taken a look at what is involved to support 3.1. Unfortunately, it is quite a bit more work than was involved in previous upgrades. This is largely due to changes that resulted from the addition of Active Relation. Although Active Relation was added in Rails 3, the latest point releases have broken some parts of the driver.

This is still planned to be addressed, but I do not have a firm date to give you. The code is hosted on GitHub, so you are welcome to go and take a look if there is anything you can contribute. I see that Shargagoz and clst have created a fork that addresses some of the compatibility issues. I have not yet had a chance to try them out yet, but you may want to take a look at it.

If the changes work for you, we can look at pulling those into the main project.

(22 Feb '12, 13:26) Eric Farrar
Comment Text Removed

Hi Eric,

Sorry for the late reply I missed your response.

Thank you for the update, glad to hear that an official update is still planned.

For now I will check out the fork as you suggested.

(06 Mar '12, 01:00) etienne
showing 3 of 7 show all flat view

Hi

Just giving you the heads up that I have created a fork that fixes the issues with calling .find, .first and .last, here: https://github.com/Sharagoz/activerecord-sqlanywhere-adapter

I'm looking into fixing the 3.1 compatibility issues as we speak.

permanent link

answered 19 Oct '11, 14:14

Sharagoz's gravatar image

Sharagoz
61126
accept rate: 0%

I have found a small problem in Sharagoz's fork when used with the latest active_scaffold. It was easily fixed thanks to the work of Sharagoz. I have created a fork here: https://github.com/clst/activerecord-sqlanywhere-adapter

Thanks for your efforts Sharagoz.

I am using this version with Rails 3.1 and the Sybase 12 client on Ubuntu 10.04 x86_64 without issues so far.

permanent link

answered 29 Nov '11, 12:50

clst's gravatar image

clst
16114
accept rate: 0%

edited 29 Nov '11, 12:53

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:

×11

question asked: 08 Sep '11, 18:30

question was seen: 1,718 times

last updated: 06 Mar '12, 01:00