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: 261ea2ffc412c3f06c841be868141f631fa9f983
4
- data.tar.gz: e5f58518bcc173eaa8be19ea24e25f086546e78c
3
+ metadata.gz: 3468167ca09838e3f5b9b5ee2194a8abf3ef0fa3
4
+ data.tar.gz: b420e7368ee61c27affe8011d521f273ae5cf66f
5
5
  SHA512:
6
- metadata.gz: 2742264fd62ee56eea953349bd95dc441d37948e2ebce6e8acb69ec200aabab5ca95e016ad7654b6626fc4bac465797abf88e3bd259f5149f2e3d60f74cae566
7
- data.tar.gz: 879d2eb8e794009a63f1d69ea85b967a126709b242cee0fd9ccac6d1ad4734e8ca62aa69413c708b47c692557e1b935ed759562caebae56bc48e85afe3269bc9
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
- base.joins_values += [build_join(base)]
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
- subqueries = build_auxiliary_statements
51
- return super if subqueries.nil?
52
- super.with(subqueries)
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 self.auxiliary_statements_values.present?
58
- self.auxiliary_statements_values.map do |klass|
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
 
@@ -1,5 +1,5 @@
1
1
  module Torque
2
2
  module PostgreSQL
3
- VERSION = '1.1.2'
3
+ VERSION = '1.1.3'
4
4
  end
5
5
  end
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.2
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: 2019-12-23 00:00:00.000000000 Z
11
+ date: 2020-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails