pg_ltree 1.1.2 → 1.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 86eb4659eb67788f154e6000003da2005f206a29
4
- data.tar.gz: 9294b256348decfa94675ddc0f55ce27b80383b9
3
+ metadata.gz: e203fa640f7e8c7f0bcacd2f8b37fe7be5b48a78
4
+ data.tar.gz: cf431e9086557ab80ddb9bc4aa5bc37ebe8ff42a
5
5
  SHA512:
6
- metadata.gz: 74f7c0d93de986082dfa58ace51c08b04547a4546931a90b85650ac4b0d6a7856b91b93717ac81e0b809e9d29afd057da5f310278ede780eeef0bc1869286eb5
7
- data.tar.gz: 842aa9982361a6e317ad7de969752701ca2b52c2748b177cf2157f279d287f5f34580e580d46c3ce574af7cca86f0ebadce686d01aa5de8a757ac97351a539d2
6
+ metadata.gz: 4f034ae0258542eb7c281b162f51cdc5d47a4e738be3fef8a9d4d1328039a6d95bfe90102fae29d356ff3ce5ab2ba676bc2560dc39dfb2abb16bf51101d61fbf
7
+ data.tar.gz: 6fb91eb800f10edf5021993f8c411659d7f2c7c3123a2dcaf65bb0117bb6f0b531cdf80bb33e26544e106dd7c2247b823d309f0ef55d42a7d69fa5d32d1497a1
data/Rakefile CHANGED
@@ -25,5 +25,4 @@ Rake::TestTask.new(:test) do |t|
25
25
  t.verbose = false
26
26
  end
27
27
 
28
-
29
28
  task default: :test
@@ -6,7 +6,6 @@ module PgLtree
6
6
  #
7
7
  # @author a.ponomarenko
8
8
  module Ltree
9
-
10
9
  # Initialzie ltree for active model
11
10
  #
12
11
  # @param column [String] ltree column name
@@ -16,8 +15,8 @@ module PgLtree
16
15
  self.ltree_path_column = column
17
16
 
18
17
  if options[:cascade]
19
- self.after_update :cascade_update
20
- self.after_destroy :cascade_destroy
18
+ after_update :cascade_update
19
+ after_destroy :cascade_destroy
21
20
  end
22
21
 
23
22
  extend ClassMethods
@@ -47,8 +46,8 @@ module PgLtree
47
46
  def leaves
48
47
  subquery =
49
48
  unscoped.select("COUNT(subquery.#{ltree_path_column}) = 1")
50
- .from("#{table_name} AS subquery")
51
- .where("subquery.#{ltree_path_column} <@ #{table_name}.#{ltree_path_column}")
49
+ .from("#{table_name} AS subquery")
50
+ .where("subquery.#{ltree_path_column} <@ #{table_name}.#{ltree_path_column}")
52
51
  subquery = subquery.where(subquery: current_scope.where_values_hash) if current_scope
53
52
  where subquery.to_sql
54
53
  end
@@ -64,7 +63,6 @@ module PgLtree
64
63
 
65
64
  # Define instance methods
66
65
  module InstanceMethods
67
-
68
66
  # Get default scope of ltree
69
67
  #
70
68
  # @return current class
@@ -100,11 +98,23 @@ module PgLtree
100
98
  depth == 1
101
99
  end
102
100
 
101
+ # Get node height
102
+ #
103
+ # The height of a node is the number of edges
104
+ # on the longest downward path between that node and a leaf. The leaf nodes have height zero,
105
+ # and a tree with only a single node (hence both a root and leaf) has height zero.
106
+ # Conventionally, an empty tree (tree with no nodes, if such are allowed) has depth and height −1
107
+ #
108
+ # @return [Number] height of the given node. Height of the tree for root node.
109
+ def height
110
+ self_and_descendants.maximum("NLEVEL(#{ltree_path_column})") - depth.to_i
111
+ end
112
+
103
113
  # Get node depth
104
114
  #
105
115
  # @return [Integer] node depth
106
116
  def depth
107
- ltree_scope.distinct.pluck("NLEVEL('#{ltree_path}')").first || nil
117
+ ActiveRecord::Base.connection.select_all("SELECT NLEVEL('#{ltree_path}')").cast_values.first
108
118
  end
109
119
 
110
120
  # Get root of the node
@@ -149,18 +159,34 @@ module PgLtree
149
159
  self_and_ancestors.where.not ltree_path_column => ltree_path
150
160
  end
151
161
 
152
- # Get self and descendents
162
+ # Get self and descendants
153
163
  #
154
164
  # @return [ActiveRecord::Relation]
155
- def self_and_descendents
165
+ def self_and_descendants
156
166
  ltree_scope.where("#{ltree_path_column} <@ ?", ltree_path)
157
167
  end
158
168
 
159
- # Get descendents
169
+ # Get self and descendants
170
+ # @deprecated Please use {#self_and_descendants} instead
171
+ # @return [ActiveRecord::Relation]
172
+ def self_and_descendents
173
+ warn '[DEPRECATION] `self_and_descendents` is deprecated. Please use `self_and_descendants` instead.'
174
+ self_and_descendants
175
+ end
176
+
177
+ # Get descendants
160
178
  #
161
179
  # @return [ActiveRecord::Relation]
180
+ def descendants
181
+ self_and_descendants.where.not ltree_path_column => ltree_path
182
+ end
183
+
184
+ # Get descendants
185
+ # @deprecated Please use {#descendants} instead
186
+ # @return [ActiveRecord::Relation]
162
187
  def descendents
163
- self_and_descendents.where.not ltree_path_column => ltree_path
188
+ warn '[DEPRECATION] `descendents` is deprecated. Please use `descendants` instead.'
189
+ descendants
164
190
  end
165
191
 
166
192
  # Get self and siblings
@@ -185,15 +211,15 @@ module PgLtree
185
211
  # @return [ActiveRecord::Relation]
186
212
  def children
187
213
  ltree_scope.where "? @> #{ltree_path_column} AND nlevel(#{ltree_path_column}) = NLEVEL(?) + 1",
188
- ltree_path, ltree_path
214
+ ltree_path, ltree_path
189
215
  end
190
216
 
191
217
  # Update all childen for current path
192
218
  #
193
219
  # @return [ActiveRecord::Relation]
194
220
  def cascade_update
195
- ltree_scope.where(["#{ltree_path_column} <@ ?", ltree_path_was]).where(["#{ltree_path_column} != ?", ltree_path]).
196
- update_all ["#{ltree_path_column} = ? || subpath(#{ltree_path_column}, nlevel(?))", ltree_path, ltree_path_was]
221
+ ltree_scope.where(["#{ltree_path_column} <@ ?", ltree_path_was]).where(["#{ltree_path_column} != ?", ltree_path])
222
+ .update_all ["#{ltree_path_column} = ? || subpath(#{ltree_path_column}, nlevel(?))", ltree_path, ltree_path_was]
197
223
  end
198
224
 
199
225
  # Delete all children for current path
@@ -4,7 +4,6 @@ module PgLtree
4
4
  #
5
5
  # @author a.ponomarenko
6
6
  module ScopedFor
7
-
8
7
  # Define base instance scope for model by columns
9
8
  #
10
9
  # @param columns [Array] List of scoped fields
@@ -18,7 +17,6 @@ module PgLtree
18
17
 
19
18
  # Define instance methods
20
19
  module InstanceMethods
21
-
22
20
  # Get default scope of ltree
23
21
  #
24
22
  # @return current class
@@ -2,7 +2,6 @@
2
2
  #
3
3
  # @author a.ponomarenko
4
4
  module PgLtree
5
-
6
5
  # Gem Version
7
- VERSION = "1.1.2"
6
+ VERSION = '1.1.3'.freeze
8
7
  end
data/lib/pg_ltree.rb CHANGED
@@ -1,5 +1,5 @@
1
- require "pg_ltree/ltree"
2
- require "pg_ltree/scoped_for"
3
- require "pg_ltree/version"
1
+ require 'pg_ltree/ltree'
2
+ require 'pg_ltree/scoped_for'
3
+ require 'pg_ltree/version'
4
4
 
5
- ActiveRecord::Base.extend(PgLtree::Ltree)
5
+ ActiveRecord::Base.extend(PgLtree::Ltree)
@@ -69,10 +69,24 @@ class PgLtree::LtreeTest < ActiveSupport::TestCase
69
69
  assert_not TreeNode.find_by(path: 'Top.Science').root?
70
70
  end
71
71
 
72
+ test '.height' do
73
+ assert_equal 4, TreeNode.find_by(path: 'Top').height
74
+ assert_equal 0, TreeNode.find_by(path: 'Top.Science.Astronomy.Astrophysics').height
75
+ end
76
+
72
77
  test '.depth' do
73
78
  assert_equal TreeNode.find_by(path: 'Top.Hobbies.Amateurs_Astronomy').depth, 3
74
79
  end
75
80
 
81
+ test '.depth on new record' do
82
+ assert_equal TreeNode.new(path: 'Top.Hobbies.Amateurs_Astronomy').depth, 3
83
+ end
84
+
85
+ test '.depth on new record when database is empty' do
86
+ TreeNode.delete_all
87
+ assert_equal TreeNode.new(path: 'Top.Hobbies.Amateurs_Astronomy').depth, 3
88
+ end
89
+
76
90
  test '.root' do
77
91
  assert_equal TreeNode.find_by(path: 'Top.Hobbies.Amateurs_Astronomy').root.path, 'Top'
78
92
  end
@@ -113,8 +127,8 @@ class PgLtree::LtreeTest < ActiveSupport::TestCase
113
127
  )
114
128
  end
115
129
 
116
- test '.self_and_descendents' do
117
- assert_equal TreeNode.find_by(path: 'Top.Science').self_and_descendents.pluck(:path), %w(
130
+ test '.self_and_descendants' do
131
+ assert_equal TreeNode.find_by(path: 'Top.Science').self_and_descendants.pluck(:path), %w(
118
132
  Top.Science
119
133
  Top.Science.Astronomy
120
134
  Top.Science.Astronomy.Astrophysics
@@ -122,8 +136,8 @@ class PgLtree::LtreeTest < ActiveSupport::TestCase
122
136
  )
123
137
  end
124
138
 
125
- test '.descendents' do
126
- assert_equal TreeNode.find_by(path: 'Top.Science').descendents.pluck(:path), %w(
139
+ test '.descendants' do
140
+ assert_equal TreeNode.find_by(path: 'Top.Science').descendants.pluck(:path), %w(
127
141
  Top.Science.Astronomy
128
142
  Top.Science.Astronomy.Astrophysics
129
143
  Top.Science.Astronomy.Cosmology
@@ -156,12 +170,12 @@ class PgLtree::LtreeTest < ActiveSupport::TestCase
156
170
  node = TreeNode.find_by(path: 'Top.Hobbies')
157
171
  node.update path: 'Top.WoW'
158
172
 
159
- assert_equal node.self_and_descendents.pluck(:path), %w(
173
+ assert_equal node.self_and_descendants.pluck(:path), %w(
160
174
  Top.WoW
161
175
  Top.WoW.Amateurs_Astronomy
162
176
  )
163
177
  end
164
-
178
+
165
179
  test '.cascade_destroy' do
166
180
  TreeNode.find_by(path: 'Top.Collections').destroy
167
181
 
@@ -115,8 +115,8 @@ class PgLtree::ScopedForTest < ActiveSupport::TestCase
115
115
  )
116
116
  end
117
117
 
118
- test '.self_and_descendents' do
119
- assert_equal not_uniq_tree_node_find_by_path('Top.Science').self_and_descendents.pluck(:new_path), %w(
118
+ test '.self_and_descendants' do
119
+ assert_equal not_uniq_tree_node_find_by_path('Top.Science').self_and_descendants.pluck(:new_path), %w(
120
120
  Top.Science
121
121
  Top.Science.Astronomy
122
122
  Top.Science.Astronomy.Astrophysics
@@ -124,8 +124,8 @@ class PgLtree::ScopedForTest < ActiveSupport::TestCase
124
124
  )
125
125
  end
126
126
 
127
- test '.descendents' do
128
- assert_equal not_uniq_tree_node_find_by_path('Top.Science').descendents.pluck(:new_path), %w(
127
+ test '.descendants' do
128
+ assert_equal not_uniq_tree_node_find_by_path('Top.Science').descendants.pluck(:new_path), %w(
129
129
  Top.Science.Astronomy
130
130
  Top.Science.Astronomy.Astrophysics
131
131
  Top.Science.Astronomy.Cosmology
@@ -153,12 +153,12 @@ class PgLtree::ScopedForTest < ActiveSupport::TestCase
153
153
  Top.Hobbies.Amateurs_Astronomy
154
154
  )
155
155
  end
156
-
156
+
157
157
  test '.cascade_update' do
158
158
  node = NotUniqTreeNode.find_by(new_path: 'Top.Hobbies', status: :active)
159
159
  node.update new_path: 'Top.WoW'
160
160
 
161
- assert_equal node.self_and_descendents.pluck(:new_path), %w(
161
+ assert_equal node.self_and_descendants.pluck(:new_path), %w(
162
162
  Top.WoW
163
163
  Top.WoW.Amateurs_Astronomy
164
164
  )
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.2
4
+ version: 1.1.3
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-15 00:00:00.000000000 Z
11
+ date: 2016-03-10 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,12 +45,14 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
+ - MIT-LICENSE
49
+ - Rakefile
50
+ - lib/pg_ltree.rb
48
51
  - lib/pg_ltree/ltree.rb
49
52
  - lib/pg_ltree/scoped_for.rb
50
53
  - lib/pg_ltree/version.rb
51
- - lib/pg_ltree.rb
52
- - MIT-LICENSE
53
- - Rakefile
54
+ - test/dummy/README.rdoc
55
+ - test/dummy/Rakefile
54
56
  - test/dummy/app/assets/javascripts/application.js
55
57
  - test/dummy/app/assets/stylesheets/application.css
56
58
  - test/dummy/app/controllers/application_controller.rb
@@ -62,9 +64,9 @@ files:
62
64
  - test/dummy/bin/rails
63
65
  - test/dummy/bin/rake
64
66
  - test/dummy/bin/setup
67
+ - test/dummy/config.ru
65
68
  - test/dummy/config/application.rb
66
69
  - test/dummy/config/boot.rb
67
- - test/dummy/config/database.yml
68
70
  - test/dummy/config/database.yml.example
69
71
  - test/dummy/config/environment.rb
70
72
  - test/dummy/config/environments/development.rb
@@ -81,19 +83,14 @@ files:
81
83
  - test/dummy/config/locales/en.yml
82
84
  - test/dummy/config/routes.rb
83
85
  - test/dummy/config/secrets.yml
84
- - test/dummy/config.ru
85
86
  - test/dummy/db/migrate/20150809114511_enable_postgres_ltree.rb
86
87
  - test/dummy/db/migrate/20150809114528_create_tree_node.rb
87
88
  - test/dummy/db/migrate/20150809114547_create_not_uniq_tree_node.rb
88
89
  - test/dummy/db/schema.rb
89
- - test/dummy/log/development.log
90
- - test/dummy/log/test.log
91
90
  - test/dummy/public/404.html
92
91
  - test/dummy/public/422.html
93
92
  - test/dummy/public/500.html
94
93
  - test/dummy/public/favicon.ico
95
- - test/dummy/Rakefile
96
- - test/dummy/README.rdoc
97
94
  - test/pg_ltree/ltree_test.rb
98
95
  - test/pg_ltree/scoped_for_test.rb
99
96
  - test/pg_ltree_test.rb
@@ -108,17 +105,17 @@ require_paths:
108
105
  - lib
109
106
  required_ruby_version: !ruby/object:Gem::Requirement
110
107
  requirements:
111
- - - '>='
108
+ - - ">="
112
109
  - !ruby/object:Gem::Version
113
110
  version: 2.0.0
114
111
  required_rubygems_version: !ruby/object:Gem::Requirement
115
112
  requirements:
116
- - - '>='
113
+ - - ">="
117
114
  - !ruby/object:Gem::Version
118
115
  version: '0'
119
116
  requirements: []
120
117
  rubyforge_project:
121
- rubygems_version: 2.0.14
118
+ rubygems_version: 2.5.1
122
119
  signing_key:
123
120
  specification_version: 4
124
121
  summary: Organise ActiveRecord model into a tree structure with PostgreSQL LTree
@@ -136,7 +133,6 @@ test_files:
136
133
  - test/dummy/bin/setup
137
134
  - test/dummy/config/application.rb
138
135
  - test/dummy/config/boot.rb
139
- - test/dummy/config/database.yml
140
136
  - test/dummy/config/database.yml.example
141
137
  - test/dummy/config/environment.rb
142
138
  - test/dummy/config/environments/development.rb
@@ -158,8 +154,6 @@ test_files:
158
154
  - test/dummy/db/migrate/20150809114528_create_tree_node.rb
159
155
  - test/dummy/db/migrate/20150809114547_create_not_uniq_tree_node.rb
160
156
  - test/dummy/db/schema.rb
161
- - test/dummy/log/development.log
162
- - test/dummy/log/test.log
163
157
  - test/dummy/public/404.html
164
158
  - test/dummy/public/422.html
165
159
  - test/dummy/public/500.html
@@ -1,14 +0,0 @@
1
- default: &default
2
- adapter: postgresql
3
- host: localhost
4
- username: postgres
5
- min_messages: warning
6
-
7
- development:
8
- <<: *default
9
- database: pg_ltree_development
10
- password: postgres
11
-
12
- test:
13
- <<: *default
14
- database: pg_ltree_test
@@ -1,204 +0,0 @@
1
-  (265.5ms) CREATE TABLE "schema_migrations" ("version" character varying NOT NULL) 
2
-  (29.4ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
3
- ActiveRecord::SchemaMigration Load (0.9ms) SELECT "schema_migrations".* FROM "schema_migrations"
4
- Migrating to EnablePostgresLtree (20150809114511)
5
-  (0.3ms) BEGIN
6
-  (449.8ms)  CREATE EXTENSION IF NOT EXISTS ltree;
7
- 
8
- SQL (17.0ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20150809114511"]]
9
-  (0.9ms) COMMIT
10
- Migrating to CreateTreeNode (20150809114528)
11
-  (0.6ms) BEGIN
12
-  (165.2ms) CREATE TABLE "tree_nodes" ("id" serial primary key, "path" ltree) 
13
- SQL (0.3ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20150809114528"]]
14
-  (0.6ms) COMMIT
15
- Migrating to CreateNotUniqTreeNode (20150809114547)
16
-  (15.6ms) BEGIN
17
-  (19.4ms) CREATE TABLE "not_uniq_tree_nodes" ("id" serial primary key, "status" character varying, "new_path" ltree) 
18
- SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20150809114547"]]
19
-  (0.7ms) COMMIT
20
- ActiveRecord::SchemaMigration Load (0.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
21
-  (2.4ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
22
- FROM pg_constraint c
23
- JOIN pg_class t1 ON c.conrelid = t1.oid
24
- JOIN pg_class t2 ON c.confrelid = t2.oid
25
- JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
26
- JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
27
- JOIN pg_namespace t3 ON c.connamespace = t3.oid
28
- WHERE c.contype = 'f'
29
- AND t1.relname = 'not_uniq_tree_nodes'
30
- AND t3.nspname = ANY (current_schemas(false))
31
- ORDER BY c.conname
32
- 
33
-  (2.1ms) SELECT t2.oid::regclass::text AS to_table, a1.attname AS column, a2.attname AS primary_key, c.conname AS name, c.confupdtype AS on_update, c.confdeltype AS on_delete
34
- FROM pg_constraint c
35
- JOIN pg_class t1 ON c.conrelid = t1.oid
36
- JOIN pg_class t2 ON c.confrelid = t2.oid
37
- JOIN pg_attribute a1 ON a1.attnum = c.conkey[1] AND a1.attrelid = t1.oid
38
- JOIN pg_attribute a2 ON a2.attnum = c.confkey[1] AND a2.attrelid = t2.oid
39
- JOIN pg_namespace t3 ON c.connamespace = t3.oid
40
- WHERE c.contype = 'f'
41
- AND t1.relname = 'tree_nodes'
42
- AND t3.nspname = ANY (current_schemas(false))
43
- ORDER BY c.conname
44
-
45
- TreeNode Load (113.1ms) SELECT "tree_nodes".* FROM "tree_nodes" ORDER BY "tree_nodes"."id" ASC LIMIT 1
46
- TreeNode Load (0.5ms) SELECT "tree_nodes".* FROM "tree_nodes" ORDER BY "tree_nodes"."id" ASC LIMIT 1
47
-  (0.4ms) BEGIN
48
- SQL (11.6ms) INSERT INTO "tree_nodes" ("path") VALUES ($1) RETURNING "id" [["path", "Top"]]
49
-  (50.3ms) COMMIT
50
-  (0.2ms) BEGIN
51
- SQL (0.3ms) INSERT INTO "tree_nodes" ("path") VALUES ($1) RETURNING "id" [["path", "Top.Science"]]
52
-  (0.4ms) COMMIT
53
-  (0.1ms) BEGIN
54
- SQL (0.2ms) INSERT INTO "tree_nodes" ("path") VALUES ($1) RETURNING "id" [["path", "Top.Science.Astronomy"]]
55
-  (0.4ms) COMMIT
56
-  (0.1ms) BEGIN
57
- SQL (0.2ms) INSERT INTO "tree_nodes" ("path") VALUES ($1) RETURNING "id" [["path", "Top.Science.Astronomy.Astrophysics"]]
58
-  (0.4ms) COMMIT
59
-  (0.1ms) BEGIN
60
- SQL (0.2ms) INSERT INTO "tree_nodes" ("path") VALUES ($1) RETURNING "id" [["path", "Top.Science.Astronomy.Cosmology"]]
61
-  (0.5ms) COMMIT
62
-  (0.2ms) BEGIN
63
- SQL (0.3ms) INSERT INTO "tree_nodes" ("path") VALUES ($1) RETURNING "id" [["path", "Top.Hobbies"]]
64
-  (0.4ms) COMMIT
65
-  (0.2ms) BEGIN
66
- SQL (0.2ms) INSERT INTO "tree_nodes" ("path") VALUES ($1) RETURNING "id" [["path", "Top.Hobbies.Amateurs_Astronomy"]]
67
-  (0.4ms) COMMIT
68
-  (0.1ms) BEGIN
69
- SQL (0.2ms) INSERT INTO "tree_nodes" ("path") VALUES ($1) RETURNING "id" [["path", "Top.Collections"]]
70
-  (0.7ms) COMMIT
71
-  (0.2ms) BEGIN
72
- SQL (0.2ms) INSERT INTO "tree_nodes" ("path") VALUES ($1) RETURNING "id" [["path", "Top.Collections.Pictures"]]
73
-  (0.4ms) COMMIT
74
-  (0.1ms) BEGIN
75
- SQL (0.2ms) INSERT INTO "tree_nodes" ("path") VALUES ($1) RETURNING "id" [["path", "Top.Collections.Pictures.Astronomy"]]
76
-  (0.4ms) COMMIT
77
-  (0.1ms) BEGIN
78
- SQL (0.2ms) INSERT INTO "tree_nodes" ("path") VALUES ($1) RETURNING "id" [["path", "Top.Collections.Pictures.Astronomy.Stars"]]
79
-  (0.4ms) COMMIT
80
-  (0.1ms) BEGIN
81
- SQL (0.2ms) INSERT INTO "tree_nodes" ("path") VALUES ($1) RETURNING "id" [["path", "Top.Collections.Pictures.Astronomy.Galaxies"]]
82
-  (0.4ms) COMMIT
83
-  (0.1ms) BEGIN
84
- SQL (0.2ms) INSERT INTO "tree_nodes" ("path") VALUES ($1) RETURNING "id" [["path", "Top.Collections.Pictures.Astronomy.Astronauts"]]
85
-  (0.4ms) COMMIT
86
- TreeNode Load (28.8ms) SELECT "tree_nodes".* FROM "tree_nodes" ORDER BY "tree_nodes"."id" ASC LIMIT 1
87
- SQL (11.9ms) UPDATE "tree_nodes" SET path = 'Top' OR subpath(path, nlevel('Top')) WHERE (path <@ 'Top')
88
- PG::InvalidTextRepresentation: ERROR: invalid input syntax for type boolean: "Top"
89
- LINE 1: UPDATE "tree_nodes" SET path = 'Top' OR subpath(path, nlevel...
90
- ^
91
- : UPDATE "tree_nodes" SET path = 'Top' OR subpath(path, nlevel('Top')) WHERE (path <@ 'Top')
92
- TreeNode Load (0.4ms) SELECT "tree_nodes".* FROM "tree_nodes" ORDER BY "tree_nodes"."id" ASC LIMIT 1
93
- SQL (0.3ms) UPDATE "tree_nodes" SET path = 'Top' OR subpath(path, nlevel('Top')) WHERE (path <@ 'Top')
94
- PG::InvalidTextRepresentation: ERROR: invalid input syntax for type boolean: "Top"
95
- LINE 1: UPDATE "tree_nodes" SET path = 'Top' OR subpath(path, nlevel...
96
- ^
97
- : UPDATE "tree_nodes" SET path = 'Top' OR subpath(path, nlevel('Top')) WHERE (path <@ 'Top')
98
- TreeNode Load (0.6ms) SELECT "tree_nodes".* FROM "tree_nodes" ORDER BY "tree_nodes"."id" ASC LIMIT 1
99
- SQL (0.5ms) UPDATE "tree_nodes" SET path = 'Top' OR subpath(path, nlevel('Top')) WHERE (path <@ 'Top')
100
- PG::InvalidTextRepresentation: ERROR: invalid input syntax for type boolean: "Top"
101
- LINE 1: UPDATE "tree_nodes" SET path = 'Top' OR subpath(path, nlevel...
102
- ^
103
- : UPDATE "tree_nodes" SET path = 'Top' OR subpath(path, nlevel('Top')) WHERE (path <@ 'Top')
104
- TreeNode Load (1.5ms) SELECT "tree_nodes".* FROM "tree_nodes" ORDER BY "tree_nodes"."id" ASC LIMIT 1
105
- SQL (20.4ms) UPDATE "tree_nodes" SET path = 'Top' OR subpath(path, nlevel('Top')) WHERE (path <@ 'Top')
106
- PG::InvalidTextRepresentation: ERROR: invalid input syntax for type boolean: "Top"
107
- LINE 1: UPDATE "tree_nodes" SET path = 'Top' OR subpath(path, nlevel...
108
- ^
109
- : UPDATE "tree_nodes" SET path = 'Top' OR subpath(path, nlevel('Top')) WHERE (path <@ 'Top')
110
-  (0.3ms) BEGIN
111
- SQL (33.9ms) INSERT INTO "not_uniq_tree_nodes" ("new_path", "status") VALUES ($1, $2) RETURNING "id" [["new_path", "Top"], ["status", "active"]]
112
-  (16.8ms) COMMIT
113
-  (0.2ms) BEGIN
114
- SQL (0.3ms) INSERT INTO "not_uniq_tree_nodes" ("new_path", "status") VALUES ($1, $2) RETURNING "id" [["new_path", "Top"], ["status", "deactive"]]
115
-  (0.5ms) COMMIT
116
-  (0.2ms) BEGIN
117
- SQL (0.3ms) INSERT INTO "not_uniq_tree_nodes" ("new_path", "status") VALUES ($1, $2) RETURNING "id" [["new_path", "Top.Science"], ["status", "active"]]
118
-  (0.5ms) COMMIT
119
-  (0.2ms) BEGIN
120
- SQL (0.3ms) INSERT INTO "not_uniq_tree_nodes" ("new_path", "status") VALUES ($1, $2) RETURNING "id" [["new_path", "Top.Science"], ["status", "deactive"]]
121
-  (0.5ms) COMMIT
122
-  (0.1ms) BEGIN
123
- SQL (0.3ms) INSERT INTO "not_uniq_tree_nodes" ("new_path", "status") VALUES ($1, $2) RETURNING "id" [["new_path", "Top.Science.Astronomy"], ["status", "active"]]
124
-  (0.4ms) COMMIT
125
-  (0.2ms) BEGIN
126
- SQL (0.3ms) INSERT INTO "not_uniq_tree_nodes" ("new_path", "status") VALUES ($1, $2) RETURNING "id" [["new_path", "Top.Science.Astronomy"], ["status", "deactive"]]
127
-  (0.5ms) COMMIT
128
-  (0.2ms) BEGIN
129
- SQL (0.3ms) INSERT INTO "not_uniq_tree_nodes" ("new_path", "status") VALUES ($1, $2) RETURNING "id" [["new_path", "Top.Science.Astronomy.Astrophysics"], ["status", "active"]]
130
-  (0.6ms) COMMIT
131
-  (0.3ms) BEGIN
132
- SQL (0.4ms) INSERT INTO "not_uniq_tree_nodes" ("new_path", "status") VALUES ($1, $2) RETURNING "id" [["new_path", "Top.Science.Astronomy.Astrophysics"], ["status", "deactive"]]
133
-  (0.5ms) COMMIT
134
-  (0.2ms) BEGIN
135
- SQL (0.2ms) INSERT INTO "not_uniq_tree_nodes" ("new_path", "status") VALUES ($1, $2) RETURNING "id" [["new_path", "Top.Science.Astronomy.Cosmology"], ["status", "active"]]
136
-  (0.4ms) COMMIT
137
-  (0.1ms) BEGIN
138
- SQL (0.3ms) INSERT INTO "not_uniq_tree_nodes" ("new_path", "status") VALUES ($1, $2) RETURNING "id" [["new_path", "Top.Science.Astronomy.Cosmology"], ["status", "deactive"]]
139
-  (0.5ms) COMMIT
140
-  (0.2ms) BEGIN
141
- SQL (0.2ms) INSERT INTO "not_uniq_tree_nodes" ("new_path", "status") VALUES ($1, $2) RETURNING "id" [["new_path", "Top.Hobbies"], ["status", "active"]]
142
-  (0.4ms) COMMIT
143
-  (0.1ms) BEGIN
144
- SQL (0.2ms) INSERT INTO "not_uniq_tree_nodes" ("new_path", "status") VALUES ($1, $2) RETURNING "id" [["new_path", "Top.Hobbies"], ["status", "deactive"]]
145
-  (0.5ms) COMMIT
146
-  (0.1ms) BEGIN
147
- SQL (0.3ms) INSERT INTO "not_uniq_tree_nodes" ("new_path", "status") VALUES ($1, $2) RETURNING "id" [["new_path", "Top.Hobbies.Amateurs_Astronomy"], ["status", "active"]]
148
-  (0.4ms) COMMIT
149
-  (0.2ms) BEGIN
150
- SQL (0.4ms) INSERT INTO "not_uniq_tree_nodes" ("new_path", "status") VALUES ($1, $2) RETURNING "id" [["new_path", "Top.Hobbies.Amateurs_Astronomy"], ["status", "deactive"]]
151
-  (0.5ms) COMMIT
152
-  (0.2ms) BEGIN
153
- SQL (0.4ms) INSERT INTO "not_uniq_tree_nodes" ("new_path", "status") VALUES ($1, $2) RETURNING "id" [["new_path", "Top.Collections"], ["status", "active"]]
154
-  (0.4ms) COMMIT
155
-  (0.2ms) BEGIN
156
- SQL (0.3ms) INSERT INTO "not_uniq_tree_nodes" ("new_path", "status") VALUES ($1, $2) RETURNING "id" [["new_path", "Top.Collections"], ["status", "deactive"]]
157
-  (0.4ms) COMMIT
158
-  (0.2ms) BEGIN
159
- SQL (0.3ms) INSERT INTO "not_uniq_tree_nodes" ("new_path", "status") VALUES ($1, $2) RETURNING "id" [["new_path", "Top.Collections.Pictures"], ["status", "active"]]
160
-  (0.5ms) COMMIT
161
-  (0.2ms) BEGIN
162
- SQL (0.3ms) INSERT INTO "not_uniq_tree_nodes" ("new_path", "status") VALUES ($1, $2) RETURNING "id" [["new_path", "Top.Collections.Pictures"], ["status", "deactive"]]
163
-  (0.6ms) COMMIT
164
-  (0.3ms) BEGIN
165
- SQL (0.4ms) INSERT INTO "not_uniq_tree_nodes" ("new_path", "status") VALUES ($1, $2) RETURNING "id" [["new_path", "Top.Collections.Pictures.Astronomy"], ["status", "active"]]
166
-  (0.6ms) COMMIT
167
-  (0.1ms) BEGIN
168
- SQL (0.2ms) INSERT INTO "not_uniq_tree_nodes" ("new_path", "status") VALUES ($1, $2) RETURNING "id" [["new_path", "Top.Collections.Pictures.Astronomy"], ["status", "deactive"]]
169
-  (0.4ms) COMMIT
170
-  (0.1ms) BEGIN
171
- SQL (0.2ms) INSERT INTO "not_uniq_tree_nodes" ("new_path", "status") VALUES ($1, $2) RETURNING "id" [["new_path", "Top.Collections.Pictures.Astronomy.Stars"], ["status", "active"]]
172
-  (0.4ms) COMMIT
173
-  (0.1ms) BEGIN
174
- SQL (0.2ms) INSERT INTO "not_uniq_tree_nodes" ("new_path", "status") VALUES ($1, $2) RETURNING "id" [["new_path", "Top.Collections.Pictures.Astronomy.Stars"], ["status", "deactive"]]
175
-  (0.4ms) COMMIT
176
-  (0.2ms) BEGIN
177
- SQL (0.4ms) INSERT INTO "not_uniq_tree_nodes" ("new_path", "status") VALUES ($1, $2) RETURNING "id" [["new_path", "Top.Collections.Pictures.Astronomy.Galaxies"], ["status", "active"]]
178
-  (0.5ms) COMMIT
179
-  (0.2ms) BEGIN
180
- SQL (0.3ms) INSERT INTO "not_uniq_tree_nodes" ("new_path", "status") VALUES ($1, $2) RETURNING "id" [["new_path", "Top.Collections.Pictures.Astronomy.Galaxies"], ["status", "deactive"]]
181
-  (0.4ms) COMMIT
182
-  (0.2ms) BEGIN
183
- SQL (0.6ms) INSERT INTO "not_uniq_tree_nodes" ("new_path", "status") VALUES ($1, $2) RETURNING "id" [["new_path", "Top.Collections.Pictures.Astronomy.Astronauts"], ["status", "active"]]
184
-  (0.4ms) COMMIT
185
-  (0.2ms) BEGIN
186
- SQL (0.2ms) INSERT INTO "not_uniq_tree_nodes" ("new_path", "status") VALUES ($1, $2) RETURNING "id" [["new_path", "Top.Collections.Pictures.Astronomy.Astronauts"], ["status", "deactive"]]
187
-  (0.4ms) COMMIT
188
- NotUniqTreeNode Load (0.5ms) SELECT "not_uniq_tree_nodes".* FROM "not_uniq_tree_nodes" WHERE "not_uniq_tree_nodes"."new_path" = $1 AND "not_uniq_tree_nodes"."status" = $2 [["new_path", "Top.Collections"], ["status", "active"]]
189
- NotUniqTreeNode Load (0.4ms) SELECT "not_uniq_tree_nodes".* FROM "not_uniq_tree_nodes" WHERE "not_uniq_tree_nodes"."new_path" = $1 AND "not_uniq_tree_nodes"."status" = $2 [["new_path", "Top.Collections"], ["status", "active"]]
190
- NotUniqTreeNode Load (0.7ms) SELECT "not_uniq_tree_nodes".* FROM "not_uniq_tree_nodes" WHERE "not_uniq_tree_nodes"."new_path" = $1 AND "not_uniq_tree_nodes"."status" = $2 [["new_path", "Top.Collections"], ["status", "active"]]
191
-  (0.2ms) BEGIN
192
- SQL (0.4ms) DELETE FROM "not_uniq_tree_nodes" WHERE "not_uniq_tree_nodes"."id" = $1 [["id", 15]]
193
- SQL (1.2ms) DELETE FROM "not_uniq_tree_nodes" WHERE "not_uniq_tree_nodes"."status" = $1 AND (new_path <@ 'Top.Collections') [["status", "active"]]
194
-  (0.5ms) COMMIT
195
- NotUniqTreeNode Load (0.5ms) SELECT "not_uniq_tree_nodes".* FROM "not_uniq_tree_nodes" WHERE "not_uniq_tree_nodes"."new_path" = $1 AND "not_uniq_tree_nodes"."status" = $2 [["new_path", "Top.Collections"], ["status", "active"]]
196
- NotUniqTreeNode Load (0.4ms) SELECT "not_uniq_tree_nodes".* FROM "not_uniq_tree_nodes" WHERE "not_uniq_tree_nodes"."new_path" = $1 AND "not_uniq_tree_nodes"."status" = $2 [["new_path", "Top.Collections"], ["status", "active"]]
197
- NotUniqTreeNode Load (0.5ms) SELECT "not_uniq_tree_nodes".* FROM "not_uniq_tree_nodes" WHERE "not_uniq_tree_nodes"."new_path" = $1 AND "not_uniq_tree_nodes"."status" = $2 [["new_path", "Top.Collections"], ["status", "active"]]
198
- NotUniqTreeNode Load (0.3ms) SELECT "not_uniq_tree_nodes".* FROM "not_uniq_tree_nodes" WHERE "not_uniq_tree_nodes"."new_path" = $1 [["new_path", "Top.Collections"]]
199
- NotUniqTreeNode Load (0.3ms) SELECT "not_uniq_tree_nodes".* FROM "not_uniq_tree_nodes" WHERE "not_uniq_tree_nodes"."new_path" = $1 LIMIT 1 [["new_path", "Top.Collections"]]
200
- NotUniqTreeNode Load (0.5ms) SELECT "not_uniq_tree_nodes".* FROM "not_uniq_tree_nodes" WHERE "not_uniq_tree_nodes"."new_path" = $1 LIMIT 1 [["new_path", "Top.Collections"]]
201
-  (0.3ms) BEGIN
202
- SQL (0.3ms) DELETE FROM "not_uniq_tree_nodes" WHERE "not_uniq_tree_nodes"."id" = $1 [["id", 16]]
203
- SQL (0.4ms) DELETE FROM "not_uniq_tree_nodes" WHERE "not_uniq_tree_nodes"."status" = $1 AND (new_path <@ 'Top.Collections') [["status", "deactive"]]
204
-  (0.5ms) COMMIT