dag_me 0.4.0 → 0.4.1

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: 74bbe571eab1c3286bee396dbe9516dff6de559e55ffe5a68bd9baa1c394db50
4
- data.tar.gz: 9e7fce79faa9157888ef20fb3aef236e2a2f0da836d5b8aaa1fde56bb95a4097
3
+ metadata.gz: 535847d509f0a7d65eb13927c894086c021addbc89017257bec5a41af5c0a547
4
+ data.tar.gz: 3c50f1a759fdbfb225897ee76cf1753073a2b24d1e3b6fa32f9c312b7cd3a7ae
5
5
  SHA512:
6
- metadata.gz: 680138923ec2d8ff9e9dec8cc048211dc82576c412b2b38f68e4bf0eb28ff12c90beb64b70ca173b5c3d16e09acb241cf9631393f78c391b26c3fd0d646e86ae
7
- data.tar.gz: 25a79cf7c541f8a03b680f22c110ebdc9b274c178c5fb5c9e95ffb1f7b5e0084a8c5a41ed7a6ef4494d358c02bf5edbefdca6530c98014130e99f1429d511041
6
+ metadata.gz: fdfb3514a36b5b892296b87113f04151881823f8102337f061425640252673b23e2ab3169cbaa2153dba09aedda4ce2fdf1b585b2f085e85492c100cc458db45
7
+ data.tar.gz: 489c29e4aaa52a208ca00f1df5766ef784e2e5e40597b155c3e8adc9ea60cef83a520318fc7957a12c534db4f036d1e903918295c0185f13eb3d99232fb5e987
data/lib/dag_me/ddl.rb CHANGED
@@ -76,6 +76,16 @@ module DagMe
76
76
  statements
77
77
  end
78
78
 
79
+ # Graph#backfill_self_rows! reuses this to repair nodes inserted with
80
+ # triggers disabled (e.g. Rails fixture loading).
81
+ def backfill_self_rows_sql
82
+ <<~SQL
83
+ INSERT INTO #{config.paths_table} (#{list(anc_cols)}, #{list(desc_cols)}, min_depth, path_count#{scope_column_list})
84
+ SELECT #{list(pk_cols)}, #{list(pk_cols)}, 0, 1#{scope_column_list} FROM #{config.node_table}
85
+ ON CONFLICT DO NOTHING;
86
+ SQL
87
+ end
88
+
79
89
  def uninstall_sql
80
90
  [
81
91
  "DROP TRIGGER IF EXISTS #{config.trigger_name('node_insert')} ON #{config.node_table};",
@@ -489,14 +499,6 @@ module DagMe
489
499
  SQL
490
500
  end
491
501
 
492
- def backfill_self_rows_sql
493
- <<~SQL
494
- INSERT INTO #{config.paths_table} (#{list(anc_cols)}, #{list(desc_cols)}, min_depth, path_count#{scope_column_list})
495
- SELECT #{list(pk_cols)}, #{list(pk_cols)}, 0, 1#{scope_column_list} FROM #{config.node_table}
496
- ON CONFLICT DO NOTHING;
497
- SQL
498
- end
499
-
500
502
  def truth_walk_sql
501
503
  <<~SQL.chomp
502
504
  WITH RECURSIVE walk(#{list(anc_cols)}, #{list(desc_cols)}, depth) AS (
data/lib/dag_me/graph.rb CHANGED
@@ -56,6 +56,18 @@ module DagMe
56
56
  self
57
57
  end
58
58
 
59
+ # Restores missing self-rows for nodes inserted with triggers disabled -
60
+ # Rails fixture loading wraps inserts in disable_referential_integrity,
61
+ # which skips the node_insert trigger. Idempotent; meant for test setups.
62
+ def backfill_self_rows!
63
+ return self unless config.closure?
64
+
65
+ model.connection_pool.with_connection do |conn|
66
+ conn.execute(DDL.new(config).backfill_self_rows_sql)
67
+ end
68
+ self
69
+ end
70
+
59
71
  # Rows where the stored closure disagrees with the recursive-CTE truth.
60
72
  # Empty means healthy.
61
73
  def validate
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DagMe
4
- VERSION = '0.4.0'
4
+ VERSION = '0.4.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dag_me
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Abdelkader Boudih