aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorTarmo Tänav <tarmo@itech.ee>2008-05-12 17:58:03 +0300
committerJeremy Kemper <jeremy@bitsweat.net>2008-06-22 16:16:06 -0700
commit509374ebe2dba0dc2ea7e44d67a6f8d530d12fac (patch)
tree6ee9f77d5f0d21c3921d0de8cf5c23bc4e0fe133 /activerecord/lib
parent2e1b56c93745bf0513e449e95830edd390abfaf2 (diff)
downloadrails-509374ebe2dba0dc2ea7e44d67a6f8d530d12fac.tar.gz
rails-509374ebe2dba0dc2ea7e44d67a6f8d530d12fac.tar.bz2
rails-509374ebe2dba0dc2ea7e44d67a6f8d530d12fac.zip
Named bind variables can now be used with postgresql-style typecasts
For example :conditions => ['stringcol::integer = :var', { :var => 10 }] will no longer raise an exception about ':integer' having a missing value.
Diffstat (limited to 'activerecord/lib')
-rwxr-xr-xactiverecord/lib/active_record/base.rb7
1 files changed, 4 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 8fca34e524..8d5ea271a7 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -2055,9 +2055,10 @@ module ActiveRecord #:nodoc:
end
def replace_named_bind_variables(statement, bind_vars) #:nodoc:
- statement.gsub(/:([a-zA-Z]\w*)/) do
- match = $1.to_sym
- if bind_vars.include?(match)
+ statement.gsub(/(:?):([a-zA-Z]\w*)/) do
+ if $1 == ':' # skip postgresql casts
+ $& # return the whole match
+ elsif bind_vars.include?(match = $2.to_sym)
quote_bound_value(bind_vars[match])
else
raise PreparedStatementInvalid, "missing value for :#{match} in #{statement}"