mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
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.
This commit is contained in:
committed by
Jeremy Kemper
parent
2e1b56c937
commit
509374ebe2
@@ -1,5 +1,6 @@
|
||||
require "cases/helper"
|
||||
require 'models/author'
|
||||
require 'models/categorization'
|
||||
require 'models/comment'
|
||||
require 'models/company'
|
||||
require 'models/topic'
|
||||
@@ -394,6 +395,12 @@ class FinderTest < ActiveRecord::TestCase
|
||||
assert_equal '1,1,1', bind('?', os)
|
||||
end
|
||||
|
||||
def test_named_bind_with_postgresql_type_casts
|
||||
l = Proc.new { bind(":a::integer '2009-01-01'::date", :a => '10') }
|
||||
assert_nothing_raised(&l)
|
||||
assert_equal "#{ActiveRecord::Base.quote_value('10')}::integer '2009-01-01'::date", l.call
|
||||
end
|
||||
|
||||
def test_string_sanitation
|
||||
assert_not_equal "#{ActiveRecord::Base.connection.quoted_string_prefix}'something ' 1=1'", ActiveRecord::Base.sanitize("something ' 1=1")
|
||||
assert_equal "#{ActiveRecord::Base.connection.quoted_string_prefix}'something; select table'", ActiveRecord::Base.sanitize("something; select table")
|
||||
|
||||
Reference in New Issue
Block a user