pg_ltree 1.1.5 → 1.1.6

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: 30020b7ecfe41a351064635d06a2c06ae10feb96
4
- data.tar.gz: '04917a96c6a478f59a1fcf0ff5ac2f6f08632d56'
3
+ metadata.gz: f2b26d6c59f672404d75047f8111c4279ba48997
4
+ data.tar.gz: 01e1adf826c8d150d244102a3db4c374b18cefb4
5
5
  SHA512:
6
- metadata.gz: ddc2d2a0dbfee906646a9ebcb0beec03e30cbe0416535d5829c48913d8a5c6f1d29df9ba00aa8c141b2af0129d4f9a62d81b94dcda64d70d53bfeaf3114f9083
7
- data.tar.gz: c9d0cc4a179dab9a8f1d45fad7c7d4954cfbdd1c79970db9248d184f4094b52412ae9a52b0f437aa623ecb75c91c8d5127bf74fb03e9aff2906187186bebcf41
6
+ metadata.gz: 2594e997cde3d85f712b3a635c55a00384e3191e34b86c0463677a1df7e57523fab057d24f6d5f4009bcc9ef5f9b999f462bc57bf6501ec30c6ffb0a7ff4cbe3
7
+ data.tar.gz: 2304afa590efe9ba7ae065f37b74479ddfe331661d95291361c773bce97c1d06b7023455d488b196a9cc4b1b276700067cc2882db0604423ff080b4af3129895
@@ -37,7 +37,7 @@ module PgLtree
37
37
  # @param depth [Integer] Depth of the nodes
38
38
  # @return [ActiveRecord::Relation] relations of nodes for the depth
39
39
  def at_depth(depth)
40
- where "NLEVEL(#{ltree_path_column}) = ?", depth
40
+ where "NLEVEL(#{table_name}.#{ltree_path_column}) = ?", depth
41
41
  end
42
42
 
43
43
  # Get all leaves
@@ -57,7 +57,7 @@ module PgLtree
57
57
  # @param lquery [String] ltree query
58
58
  # @return [ActiveRecord::Relation] relations of node'
59
59
  def where_path_liked(lquery)
60
- where "#{ltree_path_column} ~ ?", lquery
60
+ where "#{table_name}.#{ltree_path_column} ~ ?", lquery
61
61
  end
62
62
 
63
63
  # Get all nodes with path matching full-text-search-like pattern
@@ -65,7 +65,7 @@ module PgLtree
65
65
  # @param ltxtquery [String] ltree search query
66
66
  # @return [ActiveRecord::Relation] of matching nodes
67
67
  def where_path_matches_ltxtquery(ltxtquery)
68
- where "#{ltree_path_column} @ ?", ltxtquery
68
+ where "#{table_name}.#{ltree_path_column} @ ?", ltxtquery
69
69
  end
70
70
  end
71
71
 
@@ -129,21 +129,21 @@ module PgLtree
129
129
  #
130
130
  # return [Object] root node
131
131
  def root
132
- ltree_scope.where("#{ltree_path_column} = SUBPATH(?, 0, 1)", ltree_path).first
132
+ ltree_scope.where("#{ltree_scope.table_name}.#{ltree_path_column} = SUBPATH(?, 0, 1)", ltree_path).first
133
133
  end
134
134
 
135
135
  # Get parent of the node
136
136
  #
137
137
  # return [Object] root node
138
138
  def parent
139
- ltree_scope.find_by "#{ltree_path_column} = SUBPATH(?, 0, NLEVEL(?) - 1)", ltree_path, ltree_path
139
+ ltree_scope.find_by "#{ltree_scope.table_name}.#{ltree_path_column} = SUBPATH(?, 0, NLEVEL(?) - 1)", ltree_path, ltree_path
140
140
  end
141
141
 
142
142
  # Get leaves of the node
143
143
  #
144
144
  # @return [ActiveRecord::Relation]
145
145
  def leaves
146
- ltree_scope.leaves.where("#{ltree_path_column} <@ ?", ltree_path).where.not ltree_path_column => ltree_path
146
+ ltree_scope.leaves.where("#{ltree_scope.table_name}.#{ltree_path_column} <@ ?", ltree_path).where.not ltree_path_column => ltree_path
147
147
  end
148
148
 
149
149
  # Check what current node have leaves
@@ -157,7 +157,7 @@ module PgLtree
157
157
  #
158
158
  # @return [ActiveRecord::Relation]
159
159
  def self_and_ancestors
160
- ltree_scope.where("#{ltree_path_column} @> ?", ltree_path)
160
+ ltree_scope.where("#{ltree_scope.table_name}.#{ltree_path_column} @> ?", ltree_path)
161
161
  end
162
162
 
163
163
  # Get ancestors
@@ -171,7 +171,7 @@ module PgLtree
171
171
  #
172
172
  # @return [ActiveRecord::Relation]
173
173
  def self_and_descendants
174
- ltree_scope.where("#{ltree_path_column} <@ ?", ltree_path)
174
+ ltree_scope.where("#{ltree_scope.table_name}.#{ltree_path_column} <@ ?", ltree_path)
175
175
  end
176
176
 
177
177
  # Get self and descendants
@@ -202,7 +202,7 @@ module PgLtree
202
202
  # @return [ActiveRecord::Relation]
203
203
  def self_and_siblings
204
204
  ltree_scope.where(
205
- "SUBPATH(?, 0, NLEVEL(?) - 1) @> #{ltree_path_column} AND nlevel(#{ltree_path_column}) = NLEVEL(?)",
205
+ "SUBPATH(?, 0, NLEVEL(?) - 1) @> #{ltree_scope.table_name}.#{ltree_path_column} AND nlevel(#{ltree_scope.table_name}.#{ltree_path_column}) = NLEVEL(?)",
206
206
  ltree_path, ltree_path, ltree_path
207
207
  )
208
208
  end
@@ -218,7 +218,7 @@ module PgLtree
218
218
  #
219
219
  # @return [ActiveRecord::Relation]
220
220
  def children
221
- ltree_scope.where "? @> #{ltree_path_column} AND nlevel(#{ltree_path_column}) = NLEVEL(?) + 1",
221
+ ltree_scope.where "? @> #{ltree_scope.table_name}.#{ltree_path_column} AND nlevel(#{ltree_scope.table_name}.#{ltree_path_column}) = NLEVEL(?) + 1",
222
222
  ltree_path, ltree_path
223
223
  end
224
224
 
@@ -226,7 +226,7 @@ module PgLtree
226
226
  #
227
227
  # @return [ActiveRecord::Relation]
228
228
  def cascade_update
229
- ltree_scope.where(["#{ltree_path_column} <@ ?", ltree_path_was]).where(["#{ltree_path_column} != ?", ltree_path])
229
+ ltree_scope.where(["#{ltree_scope.table_name}.#{ltree_path_column} <@ ?", ltree_path_was]).where(["#{ltree_scope.table_name}.#{ltree_path_column} != ?", ltree_path])
230
230
  .update_all ["#{ltree_path_column} = ? || subpath(#{ltree_path_column}, nlevel(?))", ltree_path, ltree_path_was]
231
231
  end
232
232
 
@@ -234,7 +234,7 @@ module PgLtree
234
234
  #
235
235
  # @return [ActiveRecord::Relation]
236
236
  def cascade_destroy
237
- ltree_scope.where("#{ltree_path_column} <@ ?", ltree_path_was).delete_all
237
+ ltree_scope.where("#{ltree_scope.table_name}.#{ltree_path_column} <@ ?", ltree_path_was).delete_all
238
238
  end
239
239
  end
240
240
  end
@@ -3,5 +3,5 @@
3
3
  # @author a.ponomarenko
4
4
  module PgLtree
5
5
  # Gem Version
6
- VERSION = '1.1.5'.freeze
6
+ VERSION = '1.1.6'.freeze
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_ltree
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.5
4
+ version: 1.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrei Panamarenka
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-05 00:00:00.000000000 Z
11
+ date: 2017-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -165,9 +165,9 @@ signing_key:
165
165
  specification_version: 4
166
166
  summary: Organise ActiveRecord model into a tree structure with PostgreSQL LTree
167
167
  test_files:
168
- - test/database.yml
169
168
  - test/database.yml.sample
170
- - test/pg_ltree/ltree_test.rb
171
- - test/pg_ltree/scoped_for_test.rb
172
169
  - test/pg_ltree_test.rb
170
+ - test/database.yml
171
+ - test/pg_ltree/scoped_for_test.rb
172
+ - test/pg_ltree/ltree_test.rb
173
173
  - test/test_helper.rb