diff options
Diffstat (limited to 'app/models/namespaces/traversal/linear.rb')
-rw-r--r-- | app/models/namespaces/traversal/linear.rb | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/app/models/namespaces/traversal/linear.rb b/app/models/namespaces/traversal/linear.rb index 33e8c3e5172..d7130322ed1 100644 --- a/app/models/namespaces/traversal/linear.rb +++ b/app/models/namespaces/traversal/linear.rb @@ -74,7 +74,7 @@ module Namespaces return super unless use_traversal_ids_for_root_ancestor? strong_memoize(:root_ancestor) do - if parent.nil? + if parent_id.nil? self else Namespace.find_by(id: traversal_ids.first) @@ -176,13 +176,14 @@ module Namespaces # if you are walking up the ancestors or down the descendants. if hierarchy_order depth_sql = "ABS(#{traversal_ids.count} - array_length(traversal_ids, 1))" - skope = skope.select(skope.arel_table[Arel.star], "#{depth_sql} as depth") + skope = skope.select(skope.default_select_columns, "#{depth_sql} as depth") # The SELECT includes an extra depth attribute. We wrap the SQL in a # standard SELECT to avoid mismatched attribute errors when trying to # chain future ActiveRelation commands, and retain the ordering. skope = self.class .without_sti_condition .from(skope, self.class.table_name) + .select(skope.arel_table[Arel.star]) .order(depth: hierarchy_order) end |