activerecord-hierarchical_query 1.2.1 → 1.2.2
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/README.md +16 -14
- data/lib/active_record/hierarchical_query/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: faba4aa6eac892d19c4bc1dd40e0144722d17a2147b8fa895876731e2f34db50
|
4
|
+
data.tar.gz: 7831c15020830d2c2b913357bac349509511998019042d4c0cadf79f1bd6d8bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f55aa4774dec03dbded8f0a3d8c7d416ad10fe4b4046fa46b28424ece88eb343fd5c8fe3e19590f1bd3228f94d06f84c54796b79e9739ee82bca0b4cf939dbba
|
7
|
+
data.tar.gz: 2e612eb0fcbd96396eb7da96ca7dcb4053f8d5227bcd5ccaea7618e4d44c7bd339bbf23c740a8a3250a10df9b588294fa444f7cadec47405d73de9849f9c9424
|
data/README.md
CHANGED
@@ -13,9 +13,9 @@ in hierarchical order using hierarchical query builder.
|
|
13
13
|
|
14
14
|
## Requirements
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
- ActiveRecord >= 5.0, < 6.1
|
17
|
+
- PostgreSQL >= 8.4
|
18
|
+
- Postgres Gem >= 0.21, < 1.2
|
19
19
|
|
20
20
|
Note that though PostgresSQL 8.4 and up should work, this library
|
21
21
|
is tested on PostgresSQL 10.5.
|
@@ -130,13 +130,15 @@ end
|
|
130
130
|
|
131
131
|
Hierarchical queries consist of these important clauses:
|
132
132
|
|
133
|
-
|
133
|
+
- **START WITH** clause
|
134
134
|
|
135
135
|
This clause specifies the root row(s) of the hierarchy.
|
136
|
-
|
136
|
+
|
137
|
+
- **CONNECT BY** clause
|
137
138
|
|
138
139
|
This clause specifies relationship between parent rows and child rows of the hierarchy.
|
139
|
-
|
140
|
+
|
141
|
+
- **ORDER SIBLINGS** clause
|
140
142
|
|
141
143
|
This clause specifies an order of rows in which they appear on each hierarchy level.
|
142
144
|
|
@@ -144,16 +146,16 @@ These terms are borrowed from [Oracle hierarchical queries syntax](http://docs.o
|
|
144
146
|
|
145
147
|
Hierarchical queries are processed as follows:
|
146
148
|
|
147
|
-
|
149
|
+
- First, root rows are selected -- those rows that satisfy `START WITH` condition in
|
148
150
|
order specified by `ORDER SIBLINGS` clause. In example above it's specified by
|
149
151
|
statements `query.start_with(parent_id: nil)` and `query.order_siblings(:name)`.
|
150
152
|
|
151
|
-
|
153
|
+
- Second, child rows for each root rows are selected. Each child row must satisfy
|
152
154
|
condition specified by `CONNECT BY` clause with respect to one of the root rows
|
153
155
|
(`query.connect_by(id: :parent_id)` in example above). Order of child rows is
|
154
156
|
also specified by `ORDER SIBLINGS` clause.
|
155
157
|
|
156
|
-
|
158
|
+
- Successive generations of child rows are selected with respect to `CONNECT BY` clause.
|
157
159
|
First the children of each row selected in step 2 selected, then the children of those
|
158
160
|
children and so on.
|
159
161
|
|
@@ -342,7 +344,7 @@ ORDER BY "categories__recursive"."__order_column" ASC
|
|
342
344
|
```
|
343
345
|
|
344
346
|
If you want to use a `LEFT OUTER JOIN` instead of an `INNER JOIN`,
|
345
|
-
add a query option for `outer_join_hierarchical`.
|
347
|
+
add a query option for `outer_join_hierarchical`. This
|
346
348
|
option allows the query to return non-hierarchical entries:
|
347
349
|
|
348
350
|
```ruby
|
@@ -359,10 +361,10 @@ key of the main table to another column:
|
|
359
361
|
|
360
362
|
## Related resources
|
361
363
|
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
364
|
+
- [About hierarchical queries (Wikipedia)](http://en.wikipedia.org/wiki/Hierarchical_and_recursive_queries_in_SQL)
|
365
|
+
- [Hierarchical queries in Oracle](http://docs.oracle.com/cd/B19306_01/server.102/b14200/queries003.htm)
|
366
|
+
- [Recursive queries in PostgreSQL](http://www.postgresql.org/docs/9.3/static/queries-with.html)
|
367
|
+
- [Using Recursive SQL with ActiveRecord trees](http://hashrocket.com/blog/posts/recursive-sql-in-activerecord)
|
366
368
|
|
367
369
|
## Contributing
|
368
370
|
|
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: 1.2.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexei Mikhailov
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-
|
12
|
+
date: 2019-11-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -18,9 +18,9 @@ dependencies:
|
|
18
18
|
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '5.0'
|
21
|
-
- - "
|
21
|
+
- - "<"
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: '6.
|
23
|
+
version: '6.1'
|
24
24
|
type: :runtime
|
25
25
|
prerelease: false
|
26
26
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -28,9 +28,9 @@ dependencies:
|
|
28
28
|
- - ">="
|
29
29
|
- !ruby/object:Gem::Version
|
30
30
|
version: '5.0'
|
31
|
-
- - "
|
31
|
+
- - "<"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '6.
|
33
|
+
version: '6.1'
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: pg
|
36
36
|
requirement: !ruby/object:Gem::Requirement
|