diff options
author | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-03-16 15:40:15 -0700 |
---|---|---|
committer | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-03-16 15:40:15 -0700 |
commit | 1a6a3a1c6aa2f75333edef9100951407c4f76f1f (patch) | |
tree | 9e7e524c63e8eeabbdd6ae74ed83cc3469bfca93 /lib/active_relation/extensions | |
parent | 7f01134d1bdca70dcc9b16cf433894e7c8236815 (diff) | |
download | rails-1a6a3a1c6aa2f75333edef9100951407c4f76f1f.tar.gz rails-1a6a3a1c6aa2f75333edef9100951407c4f76f1f.tar.bz2 rails-1a6a3a1c6aa2f75333edef9100951407c4f76f1f.zip |
properly quoting array values
Diffstat (limited to 'lib/active_relation/extensions')
-rw-r--r-- | lib/active_relation/extensions/array.rb | 4 | ||||
-rw-r--r-- | lib/active_relation/extensions/hash.rb | 8 | ||||
-rw-r--r-- | lib/active_relation/extensions/object.rb | 4 |
3 files changed, 14 insertions, 2 deletions
diff --git a/lib/active_relation/extensions/array.rb b/lib/active_relation/extensions/array.rb index 4bd20d8121..3b4246fb1c 100644 --- a/lib/active_relation/extensions/array.rb +++ b/lib/active_relation/extensions/array.rb @@ -3,7 +3,7 @@ class Array Hash[*flatten] end - def to_sql(strategy = nil) - "(#{collect(&:to_sql).join(', ')})" + def to_sql(strategy = Sql::SelectExpression.new) + strategy.array self end end
\ No newline at end of file diff --git a/lib/active_relation/extensions/hash.rb b/lib/active_relation/extensions/hash.rb index a33ace5738..ae3e48146f 100644 --- a/lib/active_relation/extensions/hash.rb +++ b/lib/active_relation/extensions/hash.rb @@ -8,4 +8,12 @@ class Hash descendent.merge(yield(key) => yield(value)) end end + + def to_sql(strategy = nil) + '(' + + inject([]) do |values, (key, value)| + values << key.format(value) + end.join(', ') + + ')' + end end
\ No newline at end of file diff --git a/lib/active_relation/extensions/object.rb b/lib/active_relation/extensions/object.rb index 90eb73f0b0..2682ed99fe 100644 --- a/lib/active_relation/extensions/object.rb +++ b/lib/active_relation/extensions/object.rb @@ -3,6 +3,10 @@ class Object ActiveRelation::Value.new(self, relation) end + def to_sql(strategy = nil) + strategy.scalar self + end + def metaclass class << self self |