@ultimat3/db 31.6.1 → 31.7.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultimat3/db",
3
- "version": "31.6.1",
3
+ "version": "31.7.0",
4
4
  "description": "Postgres access, transactions, migrations and drift detection",
5
5
  "keywords": [
6
6
  "ultimate",
@@ -45,7 +45,7 @@
45
45
  "test": "bun test"
46
46
  },
47
47
  "dependencies": {
48
- "@ultimat3/core": "31.6.1"
48
+ "@ultimat3/core": "31.7.0"
49
49
  },
50
50
  "peerDependencies": {
51
51
  "@electric-sql/pglite": ">=0.5.0"
@@ -193,6 +193,11 @@ export interface HistoryDescriptionLike {
193
193
  readonly text?: readonly string[] | undefined;
194
194
  /** `timestamptz` columns the image stores as a UTC ISO string, whatever the session zone. */
195
195
  readonly instants?: readonly string[] | undefined;
196
+ /**
197
+ * Sealed columns, left out of both images: their stored string is ciphertext, and a lookup
198
+ * one is deterministic — two rows' equal values would be equal in history. Absent is none.
199
+ */
200
+ readonly sealed?: readonly string[] | undefined;
196
201
  }
197
202
 
198
203
  /** One counter, physical names: `<this table>.<column>` counts `<table>` rows by `<references>`. */
@@ -37,7 +37,10 @@ const exact = (image: string, how: { readonly type: string; readonly text: strin
37
37
  * column, the columns whose change alone records nothing (the counters the database keeps), and the
38
38
  * columns `to_jsonb` spells otherwise than the row: an `int8`/`numeric` stored as its digits (a JSON
39
39
  * number is a float to every reader past 2^53 and drops a scale's zeros), a `timestamptz` as UTC ISO
40
- * to the millisecond (`to_jsonb` writes the SESSION zone's offset) — what the memory driver keeps.
40
+ * to the millisecond (`to_jsonb` writes the SESSION zone's offset) — what the memory driver keeps —
41
+ * and the sealed columns, removed from both images before anything else reads them: ciphertext, and
42
+ * a lookup column's is deterministic, so history would compare rows the app cannot. Their change
43
+ * alone records nothing, exactly as an ignored column's.
41
44
  * An argument a trigger installed before it existed reads NULL, and NULL is the empty list.
42
45
  *
43
46
  * `jsonb_populate_record` builds the history row, so every value lands in its column's own type —
@@ -53,8 +56,10 @@ export const HISTORY_FUNCTION_SQL =
53
56
  'ignored text[] := tg_argv[3]::text[]; ' +
54
57
  "digits text[] := coalesce(tg_argv[4], '{}')::text[]; " +
55
58
  "instants text[] := coalesce(tg_argv[5], '{}')::text[]; " +
59
+ "sealed text[] := coalesce(tg_argv[6], '{}')::text[]; " +
56
60
  'k text; ' +
57
- "begin if tg_op = 'UPDATE' and (prior - ignored) = (source - ignored) then return null; end if; " +
61
+ 'begin source := source - sealed; prior := prior - sealed; ' +
62
+ "if tg_op = 'UPDATE' and (prior - ignored) = (source - ignored) then return null; end if; " +
58
63
  'foreach k in array digits loop ' +
59
64
  `${exact('source', DIGITS)} ${exact('prior', DIGITS)} end loop; ` +
60
65
  'foreach k in array instants loop ' +
@@ -116,6 +121,7 @@ export function historyTriggers(
116
121
  nameArray(history.ignore),
117
122
  nameArray(history.text ?? []),
118
123
  nameArray(history.instants ?? []),
124
+ nameArray(history.sealed ?? []),
119
125
  ].join(', ');
120
126
  return [
121
127
  [