This project is archived and is in readonly mode.
RC1 to RC2 regression : multilines where conditions autojoin with "AND"
Reported by Nicolas Blanco | August 24th, 2010 @ 10:57 AM
Hi,
the behaviour when using multilines where conditions is different between Rails 3 RC1 and Rails 3 RC2.
class User < ActiveRecord::Base
scope :test_scope,
where("active = ?
and login like ?", true, "%test%")
end
$-> rails c
Loading development environment (Rails 3.0.0.rc)
irb(main):001:0> User.test_scope.to_sql
"SELECT \"users\".* FROM \"users\" WHERE (active = 't'\n and login like '%test%')"
$-> rails c
Loading development environment (Rails 3.0.0.rc2)
irb(main):001:0> User.test_scope.to_sql
"SELECT \"users\".* FROM \"users\" WHERE (active = 't'\n AND and login like '%test%')"
As you can see in RC2, it autojoins split lines with "AND" and results in faulty SQL.
Comments and changes to this ticket
-
oleg dashevskii August 24th, 2010 @ 01:40 PM
Got bitten by it too. Quick workaround is to add backslash:
class User < ActiveRecord::Base scope :test_scope, where("active = ? \ and login like ?", true, "%test%") end
-
Brandon Tilley August 24th, 2010 @ 04:34 PM
It appears that this only happens for certain adapters. In particular, I did not have this problem on my local development machine using SQLite, but when I pushed to Heroku (which uses PostgreSQL) the bug manifested itself.
-
Thong Kuah August 24th, 2010 @ 11:12 PM
- Tag changed from arel activerecord bug rails3, activerecord, arel, rails3 to arel activerecord bug rails3, line break, activerecord, arel, rails3
-
Thong Kuah August 24th, 2010 @ 11:13 PM
- Tag changed from arel activerecord bug rails3, line break, activerecord, arel, rails3 to arel activerecord bug rails3, line break, activerecord, arel, multiline, rails3
-
oleg dashevskii August 25th, 2010 @ 06:09 AM
So, the bug confirmed with MySQL and PostgreSQL adapters.
-
Rohit Arondekar August 26th, 2010 @ 03:50 AM
- State changed from new to duplicate
- Importance changed from to Low
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>