activerecord-hierarchical_query 0.1.4 → 0.1.5
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 +4 -4
- data/lib/active_record/hierarchical_query/cte/non_recursive_term.rb +3 -2
- data/lib/active_record/hierarchical_query/cte/recursive_term.rb +1 -1
- data/lib/active_record/hierarchical_query/version.rb +1 -1
- data/spec/active_record/hierarchical_query_spec.rb +18 -0
- data/spec/schema.rb +5 -0
- data/spec/support/models.rb +6 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1549f26e6ece270b3daacb073b2a817bfd1af1fa
|
4
|
+
data.tar.gz: 8138b6f92c03fb569464026187be7a8f16d4b52d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9873c2dd645746f3d42bdcee30e77dd30e5bf0a2df2a3bb7446f978a48614feeb9b713e3c199f6c8c1a3429127f9a2851096d3bb18522faf79bff9e1065d7b62
|
7
|
+
data.tar.gz: 43272bdb02606a2b32f32b5bf282758418727fd911b98bcd0fdb8d7cdb3a4199558c1f4e96a8006511e5d11c2e5f9236dcfba9020b74d57459708e0cd8796b3b
|
@@ -29,7 +29,8 @@ module ActiveRecord
|
|
29
29
|
@scope ||= query.
|
30
30
|
start_with_value.
|
31
31
|
select(columns).
|
32
|
-
except(*DISALLOWED_CLAUSES)
|
32
|
+
except(*DISALLOWED_CLAUSES).
|
33
|
+
reorder(nil)
|
33
34
|
end
|
34
35
|
|
35
36
|
def columns
|
@@ -51,4 +52,4 @@ module ActiveRecord
|
|
51
52
|
end # class NonRecursiveTerm
|
52
53
|
end
|
53
54
|
end
|
54
|
-
end
|
55
|
+
end
|
@@ -330,4 +330,22 @@ describe ActiveRecord::HierarchicalQuery do
|
|
330
330
|
expect(result).to include(article)
|
331
331
|
end
|
332
332
|
end
|
333
|
+
|
334
|
+
describe 'Models with default scope' do
|
335
|
+
let!(:scoped_root) { ModelWithDefaultScope.create!(name: '9. Root') }
|
336
|
+
let!(:scoped_child_1) { ModelWithDefaultScope.create!(name: '8. Child', parent: scoped_root) }
|
337
|
+
let!(:scoped_child_2) { ModelWithDefaultScope.create!(name: '7. Child', parent: scoped_root) }
|
338
|
+
|
339
|
+
subject(:result) {
|
340
|
+
ModelWithDefaultScope.join_recursive do |query|
|
341
|
+
query
|
342
|
+
.connect_by(id: :parent_id)
|
343
|
+
.start_with(id: scoped_root.id)
|
344
|
+
end
|
345
|
+
}
|
346
|
+
|
347
|
+
it 'applies default scope to outer query without affecting recursive terms' do
|
348
|
+
expect(result).to eq [scoped_child_2, scoped_child_1, scoped_root]
|
349
|
+
end
|
350
|
+
end
|
333
351
|
end
|
data/spec/schema.rb
CHANGED
data/spec/support/models.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-hierarchical_query
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexei Mikhailov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|