pg_ltree 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pg_ltree/ltree.rb +4 -3
- data/lib/pg_ltree/scoped_for.rb +0 -16
- data/lib/pg_ltree/version.rb +1 -1
- metadata +15 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 86eb4659eb67788f154e6000003da2005f206a29
|
4
|
+
data.tar.gz: 9294b256348decfa94675ddc0f55ce27b80383b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74f7c0d93de986082dfa58ace51c08b04547a4546931a90b85650ac4b0d6a7856b91b93717ac81e0b809e9d29afd057da5f310278ede780eeef0bc1869286eb5
|
7
|
+
data.tar.gz: 842aa9982361a6e317ad7de969752701ca2b52c2748b177cf2157f279d287f5f34580e580d46c3ce574af7cca86f0ebadce686d01aa5de8a757ac97351a539d2
|
data/lib/pg_ltree/ltree.rb
CHANGED
@@ -46,10 +46,11 @@ module PgLtree
|
|
46
46
|
# @return [ActiveRecord::Relation] relations of node's leaves
|
47
47
|
def leaves
|
48
48
|
subquery =
|
49
|
-
select("COUNT(subquery.#{ltree_path_column}) = 1")
|
49
|
+
unscoped.select("COUNT(subquery.#{ltree_path_column}) = 1")
|
50
50
|
.from("#{table_name} AS subquery")
|
51
|
-
.where("subquery.#{ltree_path_column} <@ #{table_name}.#{ltree_path_column}")
|
52
|
-
where
|
51
|
+
.where("subquery.#{ltree_path_column} <@ #{table_name}.#{ltree_path_column}")
|
52
|
+
subquery = subquery.where(subquery: current_scope.where_values_hash) if current_scope
|
53
|
+
where subquery.to_sql
|
53
54
|
end
|
54
55
|
|
55
56
|
# Get all with nodes when path liked the lquery
|
data/lib/pg_ltree/scoped_for.rb
CHANGED
@@ -13,25 +13,9 @@ module PgLtree
|
|
13
13
|
|
14
14
|
self.ltree_scoped_for = Array.wrap(columns)
|
15
15
|
|
16
|
-
extend ClassMethods
|
17
16
|
include InstanceMethods
|
18
17
|
end
|
19
18
|
|
20
|
-
# Define class methods
|
21
|
-
module ClassMethods
|
22
|
-
|
23
|
-
# Get all leaves
|
24
|
-
#
|
25
|
-
# @return [ActiveRecord::Relation] relations of node's leaves
|
26
|
-
def leaves
|
27
|
-
subquery =
|
28
|
-
select("COUNT(subquery.#{ltree_path_column}) = (SELECT COUNT(DISTINCT #{ltree_scoped_for.first}) FROM #{table_name})")
|
29
|
-
.from("#{table_name} AS subquery")
|
30
|
-
.where("subquery.#{ltree_path_column} <@ #{table_name}.#{ltree_path_column}").to_sql
|
31
|
-
where subquery
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
19
|
# Define instance methods
|
36
20
|
module InstanceMethods
|
37
21
|
|
data/lib/pg_ltree/version.rb
CHANGED
metadata
CHANGED
@@ -1,41 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pg_ltree
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrei Panamarenka
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 4.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 4.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: pg
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 0.17.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.17.0
|
41
41
|
description: Organise ActiveRecord model into a tree structure with PostgreSQL LTree
|
@@ -45,14 +45,12 @@ executables: []
|
|
45
45
|
extensions: []
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
|
-
- MIT-LICENSE
|
49
|
-
- Rakefile
|
50
|
-
- lib/pg_ltree.rb
|
51
48
|
- lib/pg_ltree/ltree.rb
|
52
49
|
- lib/pg_ltree/scoped_for.rb
|
53
50
|
- lib/pg_ltree/version.rb
|
54
|
-
-
|
55
|
-
-
|
51
|
+
- lib/pg_ltree.rb
|
52
|
+
- MIT-LICENSE
|
53
|
+
- Rakefile
|
56
54
|
- test/dummy/app/assets/javascripts/application.js
|
57
55
|
- test/dummy/app/assets/stylesheets/application.css
|
58
56
|
- test/dummy/app/controllers/application_controller.rb
|
@@ -64,7 +62,6 @@ files:
|
|
64
62
|
- test/dummy/bin/rails
|
65
63
|
- test/dummy/bin/rake
|
66
64
|
- test/dummy/bin/setup
|
67
|
-
- test/dummy/config.ru
|
68
65
|
- test/dummy/config/application.rb
|
69
66
|
- test/dummy/config/boot.rb
|
70
67
|
- test/dummy/config/database.yml
|
@@ -84,6 +81,7 @@ files:
|
|
84
81
|
- test/dummy/config/locales/en.yml
|
85
82
|
- test/dummy/config/routes.rb
|
86
83
|
- test/dummy/config/secrets.yml
|
84
|
+
- test/dummy/config.ru
|
87
85
|
- test/dummy/db/migrate/20150809114511_enable_postgres_ltree.rb
|
88
86
|
- test/dummy/db/migrate/20150809114528_create_tree_node.rb
|
89
87
|
- test/dummy/db/migrate/20150809114547_create_not_uniq_tree_node.rb
|
@@ -94,6 +92,8 @@ files:
|
|
94
92
|
- test/dummy/public/422.html
|
95
93
|
- test/dummy/public/500.html
|
96
94
|
- test/dummy/public/favicon.ico
|
95
|
+
- test/dummy/Rakefile
|
96
|
+
- test/dummy/README.rdoc
|
97
97
|
- test/pg_ltree/ltree_test.rb
|
98
98
|
- test/pg_ltree/scoped_for_test.rb
|
99
99
|
- test/pg_ltree_test.rb
|
@@ -108,17 +108,17 @@ require_paths:
|
|
108
108
|
- lib
|
109
109
|
required_ruby_version: !ruby/object:Gem::Requirement
|
110
110
|
requirements:
|
111
|
-
- -
|
111
|
+
- - '>='
|
112
112
|
- !ruby/object:Gem::Version
|
113
113
|
version: 2.0.0
|
114
114
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
115
|
requirements:
|
116
|
-
- -
|
116
|
+
- - '>='
|
117
117
|
- !ruby/object:Gem::Version
|
118
118
|
version: '0'
|
119
119
|
requirements: []
|
120
120
|
rubyforge_project:
|
121
|
-
rubygems_version: 2.
|
121
|
+
rubygems_version: 2.0.14
|
122
122
|
signing_key:
|
123
123
|
specification_version: 4
|
124
124
|
summary: Organise ActiveRecord model into a tree structure with PostgreSQL LTree
|
@@ -170,4 +170,3 @@ test_files:
|
|
170
170
|
- test/pg_ltree/scoped_for_test.rb
|
171
171
|
- test/pg_ltree_test.rb
|
172
172
|
- test/test_helper.rb
|
173
|
-
has_rdoc:
|