Conversation
majewsky
left a comment
There was a problem hiding this comment.
I like this change in principle, but it has some corner cases where the new diffs are truncated a bit too much in my taste. For example, from running Keppel tests with this change applied in vendor/:
--- /tmp/easypg-diff1879045853/expected 2026-09-17 13:36:28.228011312 +0200
+++ /tmp/easypg-diff1879045853/actual 2026-09-17 13:36:28.228011312 +0200
@@ -1,3 +1,3 @@
UPDATE manifests SET gc_status_json = '{"protected_by_subject":"sha256:b64a08e1f12b9283b59473a4cbacb51f1b744426e0ec9abdb7cdab6db55a8075"}' WHERE repo_id = 1 AND digest = 'sha256:4710c53d191f0016fd3f84340550e38652bf9c1c8284c133757b33509c8cd78d';
UPDATE manifests SET gc_status_json = '{"relevant_policies":[{"match_repository":".*","time_constraint":{"on":"pushed_at","older_than":{"value":2,"unit":"h"}},"action":"delete"}]}' WHERE repo_id = 1 AND digest = 'sha256:b64a08e1f12b9283b59473a4cbacb51f1b744426e0ec9abdb7cdab6db55a8075';
-UPDATE repos SET next_gc_at = 7200 WHERE id = 1 AND account_name = 'test1' AND name = 'foo';
+UPDATE repos SET next_gc_at = 7200 WHERE id = 1;The additional fields shown on the red side (coming from a UNIQUE (account_name, name) constraint) add useful context without being overtly verbose.
I propose adding a method (*Tracker) ConsiderColumnsAsKey(tableName string, columnNames ...string) (feel free to bikeshed the name) which could be called as tr.ConsiderColumnsAsKey("repos", "account_name", "name") when creating the tracker.
Or alternatively, tr.ConfigureTable("repos").ConsiderColumnsAsKey("account_name", "name") with a helper type in between just to make the API read well.
|
In this case, I would rather propose to offer a function |
That would work, though it should be named |
7c567ff to
d1d7ad5
Compare
2baccaf to
19958d2
Compare
|
During implementation, I realized that I would not like a function
So I came up with the Please let me know your feedback. |
| // returned. | ||
| func (d dbSnapshot) ToSQL(prev dbSnapshot) string { | ||
| tableNames := make([]string, len(d)) | ||
| tableNames := make([]string, 0, len(d)) |
There was a problem hiding this comment.
My Copilot has flagged this, this did not cause wrong output but was still wrong.
19958d2 to
60b6fea
Compare
60b6fea to
fe33427
Compare
Merging this branch will not change overall coverage
Coverage by fileChanged files (no unit tests)
Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code. |
Follows this comment, where we got fed up with the fact that updates of the
UNIQUEkey causeDELETE+INSERTto be rendered instead ofUPDATE: sapcc/limes#952 (comment)