This project is archived and is in readonly mode.
ActiveRecord range condition with Time objects produces unquoted date strings in SQL
Reported by Daniele Orlandi | March 7th, 2010 @ 03:30 PM | in 3.0.2
Rails 3.0.0.beta, the DBMS is PostgreSQL.
I don't know if this bug is related to ActiveRecord or PostgreSQL
adaptor, however this is the issue:
I have a model "Flight" with a timestamp :takeoff_time column.
Normal range selects with numeric parameters work fine:
Flight.where(:pilot_id => 1..10).count SQL (11.2ms) SELECT COUNT(*) AS count_id FROM "flights" WHERE ("flights"."pilot_id" BETWEEN 1 AND 10)
Equal comparison with Time work fine:
Flight.where(:takeoff_time => Time::now).count SQL (0.5ms) SELECT COUNT(*) AS count_id FROM "flights" WHERE ("flights"."takeoff_time" = '2010-03-07 15:52:41.248325')
Ranges with Time with ... inclusion work fine:
Flight.where(:takeoff_time => Time::now...Time::now).count SQL (0.4ms) SELECT COUNT(*) AS count_id FROM "flights" WHERE ("flights"."takeoff_time" >= '2010-03-07 15:54:05.438399') AND ("flights"."takeoff_time" < '2010-03-07 15:54:05.438400')
.. ranges produce this:
Flight.where(:takeoff_time => Time::now..Time::now).count PGError: ERROR: syntax error at or near "16"
LINE 1: ... ("flights"."takeoff_time" BETWEEN 2010-03-07 16:53:53 +...^
: SELECT COUNT(*) AS count_id FROM "flights" WHERE ("flights"."takeoff_time" BETWEEN 2010-03-07 16:53:53 +0100 AND 2010-03-07 16:53:53 +0100)
Comments and changes to this ticket
-
Santiago Pastorino March 7th, 2010 @ 11:13 PM
- State changed from new to open
- Milestone cleared.
-
Jeremy Kemper March 7th, 2010 @ 11:27 PM
- Assigned user set to Pratik
-
Santiago Pastorino March 8th, 2010 @ 03:20 AM
I've patched arel the problem is there.
http://github.com/spastorino/arel/commit/5aec4b2391d1474472519c4238...
I sent a pull request -
Santiago Pastorino March 8th, 2010 @ 03:23 AM
- State changed from open to verified
- Tag changed from activerecord 3.0, activerecord, postgresql, rails3, range to activerecord 3.0, activerecord, patch, postgresql, rails3, range
-
Jeremy Kemper March 8th, 2010 @ 04:48 AM
- State changed from verified to resolved
Upstream issue, resolving.
-
Emilio Tagua March 8th, 2010 @ 12:29 PM
Santiago this issue is already fixed in brynary/arel:
http://github.com/brynary/arel/commit/e74bbd6830f5ca5f0ab1fe9f2f645...
You should fork this repository since now is the official one for maintenance.
-
Emilio Tagua March 8th, 2010 @ 12:30 PM
Santiago this issue is already fixed in brynary/arel:
http://github.com/brynary/arel/commit/e74bbd6830f5ca5f0ab1fe9f2f645...
You should fork this repository since now is the official one for maintenance.
-
Santiago Pastorino March 8th, 2010 @ 01:18 PM
Ok thanks, maybe a link from nkallen's arel to brynary could help.
The exercise of redoing that things was very nice anyways.Why you don't release a fixed version of arel? it's an important thing, i think.
-
Jeremy Kemper October 15th, 2010 @ 11:01 PM
- Milestone set to 3.0.2
- Importance changed from to Medium
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>