Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,3 @@ PLATFORMS
DEPENDENCIES
pg_ltree!
yard

BUNDLED WITH
1.10.5
6 changes: 4 additions & 2 deletions lib/pg_ltree/ltree.rb
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,10 @@ def children
#
# @return [ActiveRecord::Relation]
def cascade_update
ltree_scope.where(["#{ltree_path_column} <@ ?", ltree_path_was]).where(["#{ltree_path_column} != ?", ltree_path]).
update_all ["#{ltree_path_column} = ? || subpath(#{ltree_path_column}, nlevel(?))", ltree_path, ltree_path_was]
if ltree_path_was.include? self.id.to_s
ltree_scope.where(["#{ltree_path_column} <@ ?", ltree_path_was]).where(["#{ltree_path_column} != ?", ltree_path]).
update_all ["#{ltree_path_column} = ? || subpath(#{ltree_path_column}, nlevel(?))", ltree_path, ltree_path_was]
end
end

# Delete all children for current path
Expand Down