postgres_ext 2.4.0 → 2.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Rakefile +2 -0
- data/lib/postgres_ext/active_record/relation/predicate_builder.rb +1 -1
- data/lib/postgres_ext/active_record/relation/predicate_builder/array_handler.rb +1 -1
- data/lib/postgres_ext/arel/4.1/visitors/postgresql.rb +10 -1
- data/lib/postgres_ext/version.rb +1 -1
- data/test/queries/join_query_test.rb +10 -0
- data/test/test_helper.rb +7 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98ff2c9bb400e566e90b0eee78c7fbc3c4d20626
|
4
|
+
data.tar.gz: 235aeec3bafdf81928a2abadd4e19dcfdfcf26dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2fbaa25ab99012bea7aa49c91c95ccd088f8abe1b51a78b584454e661073224082782eeedca079b6d763d0fd0ac9a1ed44cfc5cd616eaa5440ab9d2b5bbbbbf5
|
7
|
+
data.tar.gz: 8991fc711864a429fcc3b95a9a76dbcd353f5723597d3027651934d5ef36208dcdf9fa3ee173dae52e821757582c7d2e39431326ad4971150564fe0ae47cd425
|
data/CHANGELOG.md
CHANGED
data/Rakefile
CHANGED
@@ -7,7 +7,7 @@ module ActiveRecord
|
|
7
7
|
when Array
|
8
8
|
engine = attribute.relation.engine
|
9
9
|
column = engine.connection.schema_cache.columns(attribute.relation.name).detect{ |col| col.name.to_s == attribute.name.to_s }
|
10
|
-
if column && column.array
|
10
|
+
if column && column.respond_to?(:array) && column.array
|
11
11
|
attribute.eq(value)
|
12
12
|
else
|
13
13
|
values = value.to_a.map {|x| x.is_a?(Base) ? x.id : x}
|
@@ -12,7 +12,7 @@ module ActiveRecord
|
|
12
12
|
def call_with_feature(attribute, value)
|
13
13
|
engine = attribute.relation.engine
|
14
14
|
column = engine.connection.schema_cache.columns(attribute.relation.name).detect{ |col| col.name.to_s == attribute.name.to_s }
|
15
|
-
if column.array
|
15
|
+
if column && column.respond_to?(:array) && column.array
|
16
16
|
attribute.eq(value)
|
17
17
|
else
|
18
18
|
call_without_feature(attribute, value)
|
@@ -6,7 +6,16 @@ module Arel
|
|
6
6
|
private
|
7
7
|
|
8
8
|
def visit_Array o, a
|
9
|
-
column = a.
|
9
|
+
column = case a.try(:relation)
|
10
|
+
when Arel::Nodes::TableAlias, NilClass
|
11
|
+
# noop Prevent from searching for table alias name in schema cache
|
12
|
+
# which won't exist for aliased table when used with Single Table
|
13
|
+
# Inheritance. see dockyard/postgres_ext#154
|
14
|
+
else
|
15
|
+
a.relation.engine.connection.schema_cache.columns(a.relation.name)
|
16
|
+
.find { |col| col.name == a.name.to_s }
|
17
|
+
end
|
18
|
+
|
10
19
|
if column && column.respond_to?(:array) && column.array
|
11
20
|
quoted o, a
|
12
21
|
else
|
data/lib/postgres_ext/version.rb
CHANGED
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
describe "Join queries" do
|
4
|
+
describe ".joins(:parent_tag) with STI" do
|
5
|
+
it 'returns a valid sql query' do
|
6
|
+
query = ChildTag.joins(:parent_tag).to_sql
|
7
|
+
query.must_match("SELECT \"tags\".* FROM \"tags\" INNER JOIN \"tags\" \"parent_tags_tags\" ON \"parent_tags_tags\".\"id\" = \"tags\".\"parent_id\" AND \"parent_tags_tags\".\"type\" IN ('ParentTag') WHERE \"tags\".\"type\" IN ('ChildTag')")
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -27,6 +27,13 @@ class Tag < ActiveRecord::Base
|
|
27
27
|
belongs_to :person
|
28
28
|
end
|
29
29
|
|
30
|
+
class ParentTag < Tag
|
31
|
+
end
|
32
|
+
|
33
|
+
class ChildTag < Tag
|
34
|
+
belongs_to :parent_tag, foreign_key: :parent_id
|
35
|
+
end
|
36
|
+
|
30
37
|
DatabaseCleaner.strategy = :deletion
|
31
38
|
|
32
39
|
class MiniTest::Spec
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: postgres_ext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.4.
|
4
|
+
version: 2.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan McClain
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -195,6 +195,7 @@ files:
|
|
195
195
|
- test/queries/array_queries_test.rb
|
196
196
|
- test/queries/common_table_expression_test.rb
|
197
197
|
- test/queries/contains_test.rb
|
198
|
+
- test/queries/join_query_test.rb
|
198
199
|
- test/queries/sanity_test.rb
|
199
200
|
- test/queries/window_functions_test.rb
|
200
201
|
- test/test_helper.rb
|
@@ -228,6 +229,7 @@ test_files:
|
|
228
229
|
- test/queries/array_queries_test.rb
|
229
230
|
- test/queries/common_table_expression_test.rb
|
230
231
|
- test/queries/contains_test.rb
|
232
|
+
- test/queries/join_query_test.rb
|
231
233
|
- test/queries/sanity_test.rb
|
232
234
|
- test/queries/window_functions_test.rb
|
233
235
|
- test/test_helper.rb
|