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. |
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. |
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. |
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?
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.
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.
Hi Eric,
That is really good news.
Hi Eric,
Have you had a chance to look at adding support for Rails 3.0.10+?
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.
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.