activerecord-hierarchical_query 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb06a2b6a2d1c5e9d77bdcae7bcd93fc648a1d0f
|
4
|
+
data.tar.gz: 0a88b8b0bb779d4bab7395b02818574c7b2559dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ae72dfaa66ce34d6a83967367afcf4d5b74883e77da4bc0b909c82d0a4fab442cd7b237e2dba8f9dc6fe6f3baa5eb2a2fbd3b297bc1481dc1a249f3110385de
|
7
|
+
data.tar.gz: d40b2571939dfb11d7579f62f03da854444bdb6555638db67b9fc735b386b5b900fec7f8aaf054b5566abcf91ab8a35b5a1b38a6616e3eefd03e663917a167b1
|
@@ -17,8 +17,8 @@ module ActiveRecord
|
|
17
17
|
|
18
18
|
def build
|
19
19
|
relation = @relation.joins(joined_arel_node)
|
20
|
-
# copy bound variables from inner subquery
|
21
|
-
relation.bind_values
|
20
|
+
# copy bound variables from inner subquery
|
21
|
+
relation.bind_values += bind_values
|
22
22
|
# add ordering by "__order_column"
|
23
23
|
relation.order_values += order_columns if ordered?
|
24
24
|
|
@@ -3,12 +3,13 @@ require 'spec_helper'
|
|
3
3
|
describe ActiveRecord::HierarchicalQuery do
|
4
4
|
let(:klass) { Category }
|
5
5
|
|
6
|
-
let
|
7
|
-
let!(:
|
8
|
-
let!(:
|
9
|
-
let!(:
|
10
|
-
let!(:
|
11
|
-
let!(:
|
6
|
+
let(:trait_id) { 'trait' }
|
7
|
+
let!(:root) { klass.create(trait_id: trait_id) }
|
8
|
+
let!(:child_1) { klass.create(parent: root, trait_id: trait_id) }
|
9
|
+
let!(:child_2) { klass.create(parent: child_1, trait_id: trait_id) }
|
10
|
+
let!(:child_3) { klass.create(parent: child_1, trait_id: trait_id) }
|
11
|
+
let!(:child_4) { klass.create(parent: root, trait_id: trait_id) }
|
12
|
+
let!(:child_5) { klass.create(parent: child_4, trait_id: trait_id) }
|
12
13
|
|
13
14
|
describe '#join_recursive' do
|
14
15
|
describe 'UNION clause' do
|
@@ -313,8 +314,9 @@ describe ActiveRecord::HierarchicalQuery do
|
|
313
314
|
let(:subquery) do
|
314
315
|
klass.join_recursive do |query|
|
315
316
|
query.
|
316
|
-
start_with(parent_id: child_1.id).
|
317
|
-
connect_by(id: :parent_id)
|
317
|
+
start_with(trait_id: trait_id, parent_id: child_1.id).
|
318
|
+
connect_by(id: :parent_id).
|
319
|
+
where(trait_id: trait_id)
|
318
320
|
end
|
319
321
|
end
|
320
322
|
|
data/spec/schema.rb
CHANGED
@@ -3,6 +3,7 @@ ActiveRecord::Migration.verbose = false
|
|
3
3
|
ActiveRecord::Schema.define(version: 0) do
|
4
4
|
create_table :categories, force: true do |t|
|
5
5
|
t.column :parent_id, :integer
|
6
|
+
t.column :trait_id, :string
|
6
7
|
t.column :name, :string
|
7
8
|
t.column :depth, :integer
|
8
9
|
t.column :position, :integer
|