real_data_tests 0.3.2 → 0.3.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
  SHA256:
3
- metadata.gz: 21f2ee14eda8fe0a048506c0ac7948c0f1c3cacb603ddb9c6490f1abef0e7fda
4
- data.tar.gz: '0698d429e6feb3f2dfd358014ff71b7cca4415d2393cbab950f99776191ec43c'
3
+ metadata.gz: 89206c96e781984f28f3efd5c3e138c15693367fcad3bf5a80bd525a7fdff88d
4
+ data.tar.gz: 40af166854587b8fe9c7e446d0ac1240aa73912bc8ebf4e21a2cebe28530b6ab
5
5
  SHA512:
6
- metadata.gz: 7839506386159938f4d5764bc0871876d7bb02ebac18ed522f23fc822e137757ea5a8a8dda7c36c4c43a91e48fa44cc0b8d69dfdca6fde402a12fe743c606fc9
7
- data.tar.gz: bc74ab0ab3c19d1766714ebe35b25c310360a7b2d0154b675b223b46e0ee8610dd37ada15de1620867895fb922cba7edaf63a3d252e2d86dcaeb070bb9716b5b
6
+ metadata.gz: 97a33efa24925c0bd452be680119d55f03a4790f1b545aa1250a2388d26cb55482b09c310094eb3d07eb2f8c0c92eadfea2f2061a7b0611d1ff15df1367680eb
7
+ data.tar.gz: e4c69341c9a4a21b6d08649b393d5594d5c6e2066a8bbf981366e377a6f7b9f2bce6aac4394ccc86026853a821aa746630b2cc49a923aee5faa4da60bbf0d6c9
data/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.3.3] - 2025-01-14
4
+ ### Fixed
5
+ - Improved circular dependency handling in PgDumpGenerator for self-referential associations
6
+ - Added robust checks for self-referential associations during topological sort
7
+ - Updated dependency graph building to properly exclude prevented circular dependencies
8
+ - Fixed model name handling in circular dependency error messages
9
+ - Improved error reporting for circular dependency detection
10
+ - Enhanced PresetConfiguration circular dependency prevention
11
+ - Added more reliable tracking of prevented reciprocal associations using Sets
12
+ - Improved handling of both class and string model names in prevention checks
13
+ - Better support for multiple prevented dependencies per model
14
+ - Updated record collection depth handling
15
+ - Fixed max depth enforcement for nested associations
16
+ - Added proper depth tracking for self-referential relationships
17
+ - Improved interaction between max depth and circular dependency prevention
18
+
3
19
  ## [0.3.2] - 2025-01-14
4
20
  ### Fixed
5
21
  - Enhanced association statistics tracking in RecordCollector
@@ -87,6 +87,14 @@ module RealDataTests
87
87
  @prevented_reciprocals << key
88
88
  end
89
89
 
90
+ def max_self_ref_depth=(depth)
91
+ @max_self_ref_depth = depth
92
+ end
93
+
94
+ def get_max_self_ref_depth(model)
95
+ @max_self_ref_depth
96
+ end
97
+
90
98
  def has_circular_dependency?(klass, association_name)
91
99
  key = if klass.is_a?(String)
92
100
  "#{klass}:#{association_name}"
@@ -34,15 +34,19 @@ module RealDataTests
34
34
 
35
35
  def build_dependency_graph(models)
36
36
  models.each_with_object({}) do |model, deps|
37
- # We only need to consider belongs_to associations since they represent
38
- # the true foreign key dependencies that affect insert order
37
+ # Get direct dependencies from belongs_to associations
39
38
  direct_dependencies = model.reflect_on_all_associations(:belongs_to)
40
39
  .reject(&:polymorphic?) # Skip polymorphic associations
40
+ .reject do |assoc|
41
+ # Skip self-referential associations that are configured to prevent circular deps
42
+ assoc.klass == model &&
43
+ RealDataTests.configuration.current_preset.prevent_reciprocal?(model, assoc.name)
44
+ end
41
45
  .map(&:klass)
42
- .select { |klass| models.include?(klass) } # Only include models we actually have records for
46
+ .select { |klass| models.include?(klass) }
43
47
  .uniq
44
48
 
45
- # For HABTM associations, we need to ensure the join tables are handled correctly
49
+ # Handle HABTM associations
46
50
  habtm_dependencies = model.reflect_on_all_associations(:has_and_belongs_to_many)
47
51
  .map { |assoc| assoc.join_table_model }
48
52
  .compact
@@ -69,9 +73,12 @@ module RealDataTests
69
73
  return if visited.include?(model)
70
74
 
71
75
  if temporary.include?(model)
72
- # Provide more context in the error message
73
- cycle = detect_cycle(model, dependencies, temporary)
74
- raise "Circular dependency detected: #{cycle.map(&:name).join(' -> ')}"
76
+ # Only raise if this isn't a prevented self-reference
77
+ unless RealDataTests.configuration.current_preset.prevent_reciprocal?(model, model.model_name.singular)
78
+ cycle = detect_cycle(model, dependencies, temporary)
79
+ raise "Circular dependency detected: #{cycle.map(&:name).join(' -> ')}"
80
+ end
81
+ return
75
82
  end
76
83
 
77
84
  temporary.add(model)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RealDataTests
4
- VERSION = "0.3.2"
4
+ VERSION = "0.3.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: real_data_tests
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Dias