torque-postgresql 1.1.2 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3468167ca09838e3f5b9b5ee2194a8abf3ef0fa3
|
4
|
+
data.tar.gz: b420e7368ee61c27affe8011d521f273ae5cf66f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e4921feec33642988fe1f231acfeeada12f68d64fd29bcce654244bed6c0ce8d8a12a6008b092e64205d4165bff7817b895ed033f9fd5dfd916dbf38a7f77ab
|
7
|
+
data.tar.gz: 0505c199a892c273cf5fe8c523a5be2028be06c319887dd1423275b17026923c99b79799a6f608203e0491cbafab64f8085300cdde0aab03ce8b7e45467c44af
|
@@ -31,11 +31,12 @@ module Torque
|
|
31
31
|
end
|
32
32
|
|
33
33
|
# Fast access to statement build
|
34
|
-
def build(statement, base, options = nil, bound_attributes = [])
|
34
|
+
def build(statement, base, options = nil, bound_attributes = [], join_sources = [])
|
35
35
|
klass = instantiate(statement, base, options)
|
36
36
|
result = klass.build(base)
|
37
37
|
|
38
38
|
bound_attributes.concat(klass.bound_attributes)
|
39
|
+
join_sources.concat(klass.join_sources)
|
39
40
|
result
|
40
41
|
end
|
41
42
|
|
@@ -105,7 +106,7 @@ module Torque
|
|
105
106
|
delegate :config, :table, :table_name, :relation, :configure, :relation_query?,
|
106
107
|
to: :class
|
107
108
|
|
108
|
-
attr_reader :bound_attributes
|
109
|
+
attr_reader :bound_attributes, :join_sources
|
109
110
|
|
110
111
|
# Start a new auxiliary statement giving extra options
|
111
112
|
def initialize(*args)
|
@@ -117,7 +118,9 @@ module Torque
|
|
117
118
|
@where = options.fetch(:where, {})
|
118
119
|
@select = options.fetch(:select, {})
|
119
120
|
@join_type = options.fetch(:join_type, nil)
|
121
|
+
|
120
122
|
@bound_attributes = []
|
123
|
+
@join_sources = []
|
121
124
|
end
|
122
125
|
|
123
126
|
# Build the statement on the given arel and return the WITH statement
|
@@ -125,7 +128,7 @@ module Torque
|
|
125
128
|
prepare(base)
|
126
129
|
|
127
130
|
# Add the join condition to the list
|
128
|
-
|
131
|
+
@join_sources << build_join(base)
|
129
132
|
|
130
133
|
# Return the statement with its dependencies
|
131
134
|
[@dependencies, ::Arel::Nodes::As.new(table, build_query(base))]
|
@@ -288,7 +291,7 @@ module Torque
|
|
288
291
|
cte.is_a?(dependent_klass)
|
289
292
|
end
|
290
293
|
|
291
|
-
AuxiliaryStatement.build(dependent, base, options, bound_attributes)
|
294
|
+
AuxiliaryStatement.build(dependent, base, options, bound_attributes, join_sources)
|
292
295
|
end
|
293
296
|
end
|
294
297
|
|
@@ -47,16 +47,16 @@ module Torque
|
|
47
47
|
|
48
48
|
# Hook arel build to add the distinct on clause
|
49
49
|
def build_arel(*)
|
50
|
-
|
51
|
-
|
52
|
-
|
50
|
+
arel = super
|
51
|
+
subqueries = build_auxiliary_statements(arel)
|
52
|
+
subqueries.nil? ? arel : arel.with(subqueries)
|
53
53
|
end
|
54
54
|
|
55
55
|
# Build all necessary data for auxiliary statements
|
56
|
-
def build_auxiliary_statements
|
57
|
-
return unless
|
58
|
-
|
59
|
-
klass.build(self)
|
56
|
+
def build_auxiliary_statements(arel)
|
57
|
+
return unless auxiliary_statements_values.present?
|
58
|
+
auxiliary_statements_values.map do |klass|
|
59
|
+
klass.build(self).tap { arel.join_sources.concat(klass.join_sources) }
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: torque-postgresql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carlos Silva
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|