activerecord-hierarchical_query 1.4.2 → 1.4.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
  SHA256:
3
- metadata.gz: 69600d117213b4b5a7955315a7c93f6101d64f5e438accf02c239ddae3759389
4
- data.tar.gz: 8c076d833d60d83e065bab8f081683765d71e824e45ad79ae8db10a85d55086f
3
+ metadata.gz: d3d4238806a983d8ef18d78dc339c337e10240e740a572c42304b9e7b5eb2ef6
4
+ data.tar.gz: 54613c3c77f471f1fceac0868de99d73e32aa3158a3d1fdd1cbb213b150bea7d
5
5
  SHA512:
6
- metadata.gz: e967554f13dff63c9a98400d99364c96b28bbc343368e0a181655b44622da3173a4096bbe5f2de78af05d40056c6ef9135f5d1762374666dfb47d288f369efcd
7
- data.tar.gz: 4f08d730fada5e0188ccb502cffa4151dcc351a2aa63061e1d634ea3c469bb876e47b2fdd886587f34e63d51abe70d23338e04dab34477ecb5a9a436479679fb
6
+ metadata.gz: 0a3321cd636c1360b661ab6a0cfeb1b7288edd414fbef695510d0400aa0dfb288c11e4b23abce8af50c02b33bbb8b8b4a108ac82d55b53ea25f7976a7960dfac
7
+ data.tar.gz: 54c6b966e88f4d8bbf57a7ebf78f6d28ae1950f3b8ee25d1f74c66c408874707f0f4cdd92f9360d62344c02c5ed87f5fd80346c28278976a21511432c17b1c85
data/README.md CHANGED
@@ -1,6 +1,5 @@
1
1
  # ActiveRecord::HierarchicalQuery
2
2
 
3
- [![Build Status](https://travis-ci.org/take-five/activerecord-hierarchical_query.png?branch=master)](https://travis-ci.org/take-five/activerecord-hierarchical_query)
4
3
  [![Code Climate](https://codeclimate.com/github/take-five/activerecord-hierarchical_query.png)](https://codeclimate.com/github/take-five/activerecord-hierarchical_query)
5
4
  [![Coverage Status](https://coveralls.io/repos/take-five/activerecord-hierarchical_query/badge.png)](https://coveralls.io/r/take-five/activerecord-hierarchical_query)
6
5
  [![Gem Version](https://badge.fury.io/rb/activerecord-hierarchical_query.png)](http://badge.fury.io/rb/activerecord-hierarchical_query)
@@ -27,12 +27,10 @@ module ActiveRecord
27
27
  order_values.each do |value|
28
28
  Array.wrap(as_orderings(value)).each do |ordering|
29
29
  @values << ordering
30
-
31
- yield ordering
32
30
  end
33
31
  end
34
32
 
35
- @values
33
+ @values.each(&block)
36
34
  end
37
35
 
38
36
  # Returns order expression to be inserted into SELECT clauses of both
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module HierarchicalQuery
3
- VERSION = '1.4.2'
3
+ VERSION = '1.4.3'
4
4
  end
5
5
  end
@@ -120,11 +120,6 @@ describe ActiveRecord::HierarchicalQuery do
120
120
  assert_ordered_by_name_desc { order_siblings(name: :desc) }
121
121
  end
122
122
 
123
- it 'orders rows by String' do
124
- assert_ordered_by_name_desc { order_siblings('name desc') }
125
- assert_ordered_by_name_asc { order_siblings('name asc') }
126
- end
127
-
128
123
  it 'orders rows by Arel::Nodes::Ordering' do
129
124
  assert_ordered_by_name_desc { order_siblings(table[:name].desc) }
130
125
  end
@@ -153,6 +148,26 @@ describe ActiveRecord::HierarchicalQuery do
153
148
  expect(relation.to_sql).not_to match /row_number/i
154
149
  end
155
150
  end
151
+
152
+ context 'when ordering by String' do
153
+ it 'orders rows by one column' do
154
+ assert_ordered_by_name_desc { order_siblings('name desc') }
155
+ assert_ordered_by_name_asc { order_siblings('name asc') }
156
+ end
157
+
158
+ it 'orders rows by multiple columns' do
159
+ root.update!(name: "Root", trait_id: "a")
160
+ child_2.update!(name: 'Same Name', trait_id: 'a')
161
+ child_3.update!(name: 'Same Name', trait_id: 'b')
162
+ root2 = klass.create(name: "Root", trait_id: "b")
163
+
164
+ expect(
165
+ klass.join_recursive do |b|
166
+ b.connect_by(id: :parent_id).start_with(parent_id: nil).order_siblings('name asc, trait_id desc')
167
+ end
168
+ ).to eq [root2, root, child_1, child_3, child_2, child_4, child_5]
169
+ end
170
+ end
156
171
  end
157
172
 
158
173
  describe 'LIMIT and OFFSET clauses' do
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-hierarchical_query
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.2
4
+ version: 1.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexei Mikhailov
8
8
  - Zach Aysan
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-11-23 00:00:00.000000000 Z
12
+ date: 2023-04-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -121,7 +121,7 @@ dependencies:
121
121
  - - "~>"
122
122
  - !ruby/object:Gem::Version
123
123
  version: '0.16'
124
- description:
124
+ description:
125
125
  email:
126
126
  - amikhailov83@gmail.com
127
127
  - zachaysan@gmail.com
@@ -154,7 +154,7 @@ homepage: https://github.com/take-five/activerecord-hierarchical_query
154
154
  licenses:
155
155
  - MIT
156
156
  metadata: {}
157
- post_install_message:
157
+ post_install_message:
158
158
  rdoc_options: []
159
159
  require_paths:
160
160
  - lib
@@ -169,8 +169,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
169
169
  - !ruby/object:Gem::Version
170
170
  version: '0'
171
171
  requirements: []
172
- rubygems_version: 3.4.0.dev
173
- signing_key:
172
+ rubygems_version: 3.4.1
173
+ signing_key:
174
174
  specification_version: 4
175
175
  summary: Recursively traverse trees using a single SQL query
176
176
  test_files: