Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Make sure range strings are quoted after we quote the range.
- Loading branch information
1 parent
f17b04a
commit c1156bf
Showing
3 changed files
with
28 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| require "cases/helper" | ||
|
|
||
| if ActiveRecord::Base.connection.supports_ranges? | ||
| class PostgresqlRange < ActiveRecord::Base | ||
| self.table_name = "postgresql_ranges" | ||
| end | ||
|
|
||
| class PostgresqlRangeTest < ActiveRecord::TestCase | ||
| test "update_all with ranges" do | ||
| PostgresqlRange.create! | ||
|
|
||
| PostgresqlRange.update_all(int8_range: 1..100) | ||
|
|
||
| assert_equal 1...101, PostgresqlRange.first.int8_range | ||
| end | ||
|
|
||
| test "ranges correctly escape input" do | ||
| e = assert_raises(ActiveRecord::StatementInvalid) do | ||
| range = "1,2]'; SELECT * FROM users; --".."a" | ||
| PostgresqlRange.update_all(int8_range: range) | ||
| end | ||
|
|
||
| assert e.message.starts_with?("PG::InvalidTextRepresentation") | ||
| end | ||
| end | ||
| end |