closure_tree 9.1.1 → 9.2.0

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
  SHA256:
3
- metadata.gz: 4a3ac565445f8b4e6054dd67fe023b025db79b17a2d16af5ba8804f190142e37
4
- data.tar.gz: d7e7af95d8ef2b2f01c17248e31aaf3b1c7c51109670fc88fefb9343934ee8ff
3
+ metadata.gz: ace270a69b46da9e3ba8594cb5299e0eb3d9b222f3261c6304566cdbe1f5c7bd
4
+ data.tar.gz: ea4dccd196cf9278d510f89fa62d5e892916f2effa82b9c08cf851305523d528
5
5
  SHA512:
6
- metadata.gz: 9ecedfd06bac1b6d234c05624730b74c93b34d8ba1cb81b09653f7af3bea42d17f0154d471a7f8c0bbc842981a2a1e1260b061a51fbec4cba49f9963f7aced9c
7
- data.tar.gz: 8a329d9a4483a36411515789d2d596905a27501dada6ef77f25cb0b34c3154eb3c5aad0aef28f9e4978987d33587d352a4027dd2cc0d7acf422970729e195151
6
+ metadata.gz: 6f915001574717ed1bbadf7f528a6d8d04aa1143cf3ca736db3c1649e72cf4e0d3a60303df86456b6f5ab86a8b1a819987475361a6497f2488f3768ff243dc68
7
+ data.tar.gz: 865de6b37ea0db45a27852799e2853b37091f32e06e28a405123e429275a05c7591069039f878cf26f6064e0e5d58ad67c9d227ef8911c2092667f009b4610f5
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## [9.2.0](https://github.com/ClosureTree/closure_tree/compare/closure_tree/v9.1.1...closure_tree/v9.2.0) (2025-10-17)
4
+
5
+
6
+ ### Features
7
+
8
+ * add PostgreSQL schema-qualified table name support ([#462](https://github.com/ClosureTree/closure_tree/issues/462)) ([5f9006c](https://github.com/ClosureTree/closure_tree/commit/5f9006cece95a76f665cb50c2615317e3fa48586))
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * add implicit_order_column for Rails 8.1+ compatibility ([#464](https://github.com/ClosureTree/closure_tree/issues/464)) ([f384303](https://github.com/ClosureTree/closure_tree/commit/f38430334a79ea15d236f9212118dcb5e4530746))
14
+
3
15
  ## [9.1.1](https://github.com/ClosureTree/closure_tree/compare/closure_tree/v9.1.0...closure_tree/v9.1.1) (2025-07-24)
4
16
 
5
17
 
data/README.md CHANGED
@@ -343,7 +343,7 @@ When you include ```has_closure_tree``` in your model, you can provide a hash to
343
343
  * ```tag.child?``` returns true if this is a child node. It has a parent.
344
344
  * ```tag.leaf?``` returns true if this is a leaf node. It has no children.
345
345
  * ```tag.leaves``` is scoped to all leaf nodes in self_and_descendants.
346
- * ```tag.depth``` returns the depth, or "generation", for this node in the tree. A root node will have a value of 0.
346
+ * ```tag.depth``` returns the depth, or "generation", for this node in the tree. A root node will have a value of 0. Also aliased as `level`.
347
347
  * ```tag.parent``` returns the node's immediate parent. Root nodes will return nil.
348
348
  * ```tag.parent_of?(node)``` returns true if current node is parent of another one
349
349
  * ```tag.children``` is a ```has_many``` of immediate children (just those nodes whose parent is the current node).
@@ -33,6 +33,9 @@ module ClosureTree
33
33
  hierarchy_class = parent_class.const_set(short_hierarchy_class_name, Class.new(model_class.superclass))
34
34
  model_class_name = model_class.to_s
35
35
  hierarchy_class.class_eval do
36
+ # Rails 8.1+ requires an implicit_order_column for models without a primary key
37
+ self.implicit_order_column = 'ancestor_id'
38
+
36
39
  belongs_to :ancestor, class_name: model_class_name
37
40
  belongs_to :descendant, class_name: model_class_name
38
41
  def ==(other)
@@ -51,8 +54,19 @@ module ClosureTree
51
54
  # We need to use the table_name, not something like ct_class.to_s.demodulize + "_hierarchies",
52
55
  # because they may have overridden the table name, which is what we want to be consistent with
53
56
  # in order for the schema to make sense.
54
- tablename = options[:hierarchy_table_name] ||
55
- "#{remove_prefix_and_suffix(table_name, model_class).singularize}_hierarchies"
57
+ if options[:hierarchy_table_name]
58
+ tablename = options[:hierarchy_table_name]
59
+ else
60
+ base_table = remove_prefix_and_suffix(table_name, model_class)
61
+
62
+ # Handle PostgreSQL schema-qualified table names (e.g., "my_schema.table_name")
63
+ schema, _, table = base_table.rpartition('.')
64
+ if schema.present?
65
+ tablename = "#{schema}.#{table.singularize}_hierarchies"
66
+ else
67
+ tablename = "#{table.singularize}_hierarchies"
68
+ end
69
+ end
56
70
 
57
71
  [model_class.table_name_prefix, tablename, model_class.table_name_suffix].join
58
72
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ClosureTree
4
- VERSION = Gem::Version.new('9.1.1')
4
+ VERSION = Gem::Version.new('9.2.0')
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: closure_tree
3
3
  version: !ruby/object:Gem::Version
4
- version: 9.1.1
4
+ version: 9.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew McEachen
@@ -178,7 +178,7 @@ licenses:
178
178
  metadata:
179
179
  bug_tracker_uri: https://github.com/ClosureTree/closure_tree/issues
180
180
  changelog_uri: https://github.com/ClosureTree/closure_tree/blob/master/CHANGELOG.md
181
- documentation_uri: https://www.rubydoc.info/gems/closure_tree/9.1.1
181
+ documentation_uri: https://www.rubydoc.info/gems/closure_tree/9.2.0
182
182
  homepage_uri: https://closuretree.github.io/closure_tree/
183
183
  source_code_uri: https://github.com/ClosureTree/closure_tree
184
184
  rubygems_mfa_required: 'true'