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 +4 -4
- data/lib/dag_me/ddl.rb +10 -8
- data/lib/dag_me/graph.rb +12 -0
- data/lib/dag_me/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 535847d509f0a7d65eb13927c894086c021addbc89017257bec5a41af5c0a547
|
|
4
|
+
data.tar.gz: 3c50f1a759fdbfb225897ee76cf1753073a2b24d1e3b6fa32f9c312b7cd3a7ae
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
data/lib/dag_me/version.rb
CHANGED