activerecord-hierarchical_query 0.1.3 → 0.1.4

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: b3857ae3686fc8bc70d3fa51f68ce8b179c74565
4
- data.tar.gz: 8ff21aff761065bdc8fe7af742607a53f1488b7f
3
+ metadata.gz: fb06a2b6a2d1c5e9d77bdcae7bcd93fc648a1d0f
4
+ data.tar.gz: 0a88b8b0bb779d4bab7395b02818574c7b2559dd
5
5
  SHA512:
6
- metadata.gz: 47ba81111606890e77d4decb8b1dcb8e9f10ae0ff985b74aab7309133c159294227bed679b7d748ee644aa4646fac8eb29404bee0cdfede1689f15a35dded15b
7
- data.tar.gz: 2d474936f08750e56f9a467d07ef8bc110e099154907f260f31f579ffed75690c9f70c384e6ca3cc48bb61f56706a26ef1f06298808a1fba77cec5576b66f0ca
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 (remove duplicates)
21
- relation.bind_values |= 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
 
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module HierarchicalQuery
3
- VERSION = '0.1.3'
3
+ VERSION = '0.1.4'
4
4
  end
5
5
  end
@@ -3,12 +3,13 @@ require 'spec_helper'
3
3
  describe ActiveRecord::HierarchicalQuery do
4
4
  let(:klass) { Category }
5
5
 
6
- let!(:root) { klass.create }
7
- let!(:child_1) { klass.create(parent: root) }
8
- let!(:child_2) { klass.create(parent: child_1) }
9
- let!(:child_3) { klass.create(parent: child_1) }
10
- let!(:child_4) { klass.create(parent: root) }
11
- let!(:child_5) { klass.create(parent: child_4) }
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-hierarchical_query
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexei Mikhailov