This project is archived and is in readonly mode.
Arel/AR prepending 'AND' unconditionally after newlines in string literals in RC2
-
Brian Lopez
- Tag changed from pink warrior rc2 arel to pink warrior, arel, rc2
-
José Valim
- Milestone cleared.
- State changed from new to open
- Importance changed from to High
-
Dim
Got it, I found the issue!
In http://github.com/rails/arel/blob/master/lib/arel/algebra/relations... the clause is passed to Array(clause), therefore:
> Array(%("table"."some_column" = 'some\nvalue')) => ["\"table\".\"some_column\" = 'some\n", "value'"] -
Brian Lopez
Wow, didn't realize Array() would treat newlines like that...
-
José Valim
Yup, it does! This is why in Rails we usually use Array.wrap.
-
Brian Lopez
For reference, this was the commit that changed to using Array(): http://github.com/rails/arel/commit/bef0d30e30b99c8e56325645a9f643b...
-
Dim
Just to confirm:
ruby-1.9.2-rc2 > Array("a\nb") => ["a\nb"] ree-1.8.7-2010.02 > Array("a\nb") => ["a\n", "b"] -
Brian Lopez
If I remember correctly, Aaron made this change for performance reasons so whatever solution we end up figuring out should hopefully be performant; if at all possible.
-
Xavier Noria
Yeah I was in a hurry before. I mean, Array() has that gotcha and AS implements Array.wrap for that reason. If it makes sense it's there. If there's only one place where it is used then some simple Ruby may be better. (But the next guy may wonder why Array() wasn't used, so perhaps with a comment?)
-
Aaron Patterson
I'm on it. I'll have a fix for this later today. I'm super jet lagged right now. :'(
-
Aaron Patterson
- State changed from open to resolved
Should be fixed here:
http://github.com/rails/arel/commit/6333a2bd526cc4d09833aaf94c8cf1e...