aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/adapters/postgresql
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2016-08-07 00:41:24 +0900
committerRyuta Kamizono <kamipo@gmail.com>2016-08-11 22:30:40 +0900
commitf79d55a4cca155171c6d16c3c07834ba43d572c2 (patch)
tree8b3fd9e852f7a619f8011ce131b7ce14f6e8d5c3 /activerecord/test/cases/adapters/postgresql
parentb9f71e49ae43c53258da95bda50325a8d0c99a52 (diff)
downloadrails-f79d55a4cca155171c6d16c3c07834ba43d572c2.tar.gz
rails-f79d55a4cca155171c6d16c3c07834ba43d572c2.tar.bz2
rails-f79d55a4cca155171c6d16c3c07834ba43d572c2.zip
`where` by `array|range` attribute with array or range value
Currently predicate builder cannot build a predicate for `array|range` attribute. This commit fixes the issue. Related #25671.
Diffstat (limited to 'activerecord/test/cases/adapters/postgresql')
-rw-r--r--activerecord/test/cases/adapters/postgresql/array_test.rb6
-rw-r--r--activerecord/test/cases/adapters/postgresql/range_test.rb6
2 files changed, 12 insertions, 0 deletions
diff --git a/activerecord/test/cases/adapters/postgresql/array_test.rb b/activerecord/test/cases/adapters/postgresql/array_test.rb
index e496960f21..ec98c65189 100644
--- a/activerecord/test/cases/adapters/postgresql/array_test.rb
+++ b/activerecord/test/cases/adapters/postgresql/array_test.rb
@@ -290,6 +290,12 @@ class PostgresqlArrayTest < ActiveRecord::PostgreSQLTestCase
assert_equal record.tags, record.reload.tags
end
+ def test_where_by_attribute_with_array
+ tags = ["black", "blue"]
+ record = PgArray.create!(tags: tags)
+ assert_equal record, PgArray.where(tags: tags).take
+ end
+
def test_uniqueness_validation
klass = Class.new(PgArray) do
validates_uniqueness_of :tags
diff --git a/activerecord/test/cases/adapters/postgresql/range_test.rb b/activerecord/test/cases/adapters/postgresql/range_test.rb
index 3f819f7bd5..f411884dfd 100644
--- a/activerecord/test/cases/adapters/postgresql/range_test.rb
+++ b/activerecord/test/cases/adapters/postgresql/range_test.rb
@@ -282,6 +282,12 @@ _SQL
assert_raises(ArgumentError) { PostgresqlRange.create!(tstz_range: "(''2010-01-01 14:30:00+05'', ''2011-01-01 14:30:00-03'']") }
end
+ def test_where_by_attribute_with_range
+ range = 1..100
+ record = PostgresqlRange.create!(int4_range: range)
+ assert_equal record, PostgresqlRange.where(int4_range: range).take
+ end
+
def test_update_all_with_ranges
PostgresqlRange.create!