diff options
author | Sean Griffin <sean@thoughtbot.com> | 2014-07-03 07:16:06 -0600 |
---|---|---|
committer | Sean Griffin <sean@thoughtbot.com> | 2014-07-05 07:23:08 -0600 |
commit | 02579b56bbe0de17ce8657f453ad4f02acc4ab84 (patch) | |
tree | d3bde3bc313d1e49dbda7c221f2b396b093ab2b9 /activerecord/test/cases/adapters/postgresql | |
parent | 082d1e38cb146cb73256643cbd2972f9028ac8f2 (diff) | |
download | rails-02579b56bbe0de17ce8657f453ad4f02acc4ab84.tar.gz rails-02579b56bbe0de17ce8657f453ad4f02acc4ab84.tar.bz2 rails-02579b56bbe0de17ce8657f453ad4f02acc4ab84.zip |
Use the type object for quoting PG Ranges
Diffstat (limited to 'activerecord/test/cases/adapters/postgresql')
-rw-r--r-- | activerecord/test/cases/adapters/postgresql/quoting_test.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/adapters/postgresql/range_test.rb | 10 |
2 files changed, 6 insertions, 6 deletions
diff --git a/activerecord/test/cases/adapters/postgresql/quoting_test.rb b/activerecord/test/cases/adapters/postgresql/quoting_test.rb index 59c274c759..11d5173d37 100644 --- a/activerecord/test/cases/adapters/postgresql/quoting_test.rb +++ b/activerecord/test/cases/adapters/postgresql/quoting_test.rb @@ -61,7 +61,7 @@ module ActiveRecord def test_quote_range range = "1,2]'; SELECT * FROM users; --".."a" c = PostgreSQLColumn.new(nil, nil, OID::Range.new(Type::Integer.new, :int8range)) - assert_equal "'[1,2]''; SELECT * FROM users; --,a]'::int8range", @conn.quote(range, c) + assert_equal "'[1,0]'", @conn.quote(range, c) end def test_quote_bit_string diff --git a/activerecord/test/cases/adapters/postgresql/range_test.rb b/activerecord/test/cases/adapters/postgresql/range_test.rb index 02d0a9b483..d812cd01c4 100644 --- a/activerecord/test/cases/adapters/postgresql/range_test.rb +++ b/activerecord/test/cases/adapters/postgresql/range_test.rb @@ -271,12 +271,12 @@ _SQL end def test_ranges_correctly_escape_input - e = assert_raises(ActiveRecord::StatementInvalid) do - range = "1,2]'; SELECT * FROM users; --".."a" - PostgresqlRange.update_all(int8_range: range) - end + range = "-1,2]'; DROP TABLE postgresql_ranges; --".."a" + PostgresqlRange.update_all(int8_range: range) - assert e.message.starts_with?("PG::InvalidTextRepresentation") + assert_nothing_raised do + PostgresqlRange.first + end end private |