@spinajs/orm 2.0.519 → 2.0.521

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.
Files changed (95) hide show
  1. package/lib/cjs/builders.d.ts +1 -0
  2. package/lib/cjs/builders.d.ts.map +1 -1
  3. package/lib/cjs/builders.js +10 -1
  4. package/lib/cjs/builders.js.map +1 -1
  5. package/lib/cjs/converters.d.ts.map +1 -1
  6. package/lib/cjs/converters.js +12 -5
  7. package/lib/cjs/converters.js.map +1 -1
  8. package/lib/cjs/decorators.d.ts.map +1 -1
  9. package/lib/cjs/decorators.js +41 -4
  10. package/lib/cjs/decorators.js.map +1 -1
  11. package/lib/cjs/interfaces.d.ts +10 -9
  12. package/lib/cjs/interfaces.d.ts.map +1 -1
  13. package/lib/cjs/interfaces.js.map +1 -1
  14. package/lib/cjs/metadata.d.ts.map +1 -1
  15. package/lib/cjs/metadata.js +0 -1
  16. package/lib/cjs/metadata.js.map +1 -1
  17. package/lib/cjs/model.d.ts +72 -53
  18. package/lib/cjs/model.d.ts.map +1 -1
  19. package/lib/cjs/model.js +155 -104
  20. package/lib/cjs/model.js.map +1 -1
  21. package/lib/cjs/relation-objects.d.ts +9 -4
  22. package/lib/cjs/relation-objects.d.ts.map +1 -1
  23. package/lib/cjs/relation-objects.js +15 -13
  24. package/lib/cjs/relation-objects.js.map +1 -1
  25. package/lib/cjs/relations.d.ts.map +1 -1
  26. package/lib/cjs/relations.js +16 -1
  27. package/lib/cjs/relations.js.map +1 -1
  28. package/lib/cjs/snapshot.d.ts +12 -0
  29. package/lib/cjs/snapshot.d.ts.map +1 -1
  30. package/lib/cjs/snapshot.js +9 -0
  31. package/lib/cjs/snapshot.js.map +1 -1
  32. package/lib/cjs/statements.d.ts +11 -0
  33. package/lib/cjs/statements.d.ts.map +1 -1
  34. package/lib/cjs/statements.js +24 -0
  35. package/lib/cjs/statements.js.map +1 -1
  36. package/lib/cjs/subject-builder.d.ts +3 -2
  37. package/lib/cjs/subject-builder.d.ts.map +1 -1
  38. package/lib/cjs/subject-builder.js +10 -9
  39. package/lib/cjs/subject-builder.js.map +1 -1
  40. package/lib/cjs/subject-executor.d.ts +2 -2
  41. package/lib/cjs/subject-executor.d.ts.map +1 -1
  42. package/lib/cjs/subject-executor.js +11 -8
  43. package/lib/cjs/subject-executor.js.map +1 -1
  44. package/lib/cjs/subject.d.ts +8 -1
  45. package/lib/cjs/subject.d.ts.map +1 -1
  46. package/lib/cjs/subject.js.map +1 -1
  47. package/lib/mjs/builders.d.ts +1 -0
  48. package/lib/mjs/builders.d.ts.map +1 -1
  49. package/lib/mjs/builders.js +10 -1
  50. package/lib/mjs/builders.js.map +1 -1
  51. package/lib/mjs/converters.d.ts.map +1 -1
  52. package/lib/mjs/converters.js +12 -5
  53. package/lib/mjs/converters.js.map +1 -1
  54. package/lib/mjs/decorators.d.ts.map +1 -1
  55. package/lib/mjs/decorators.js +41 -4
  56. package/lib/mjs/decorators.js.map +1 -1
  57. package/lib/mjs/interfaces.d.ts +10 -9
  58. package/lib/mjs/interfaces.d.ts.map +1 -1
  59. package/lib/mjs/interfaces.js.map +1 -1
  60. package/lib/mjs/metadata.d.ts.map +1 -1
  61. package/lib/mjs/metadata.js +0 -1
  62. package/lib/mjs/metadata.js.map +1 -1
  63. package/lib/mjs/model.d.ts +72 -53
  64. package/lib/mjs/model.d.ts.map +1 -1
  65. package/lib/mjs/model.js +156 -105
  66. package/lib/mjs/model.js.map +1 -1
  67. package/lib/mjs/relation-objects.d.ts +9 -4
  68. package/lib/mjs/relation-objects.d.ts.map +1 -1
  69. package/lib/mjs/relation-objects.js +15 -13
  70. package/lib/mjs/relation-objects.js.map +1 -1
  71. package/lib/mjs/relations.d.ts.map +1 -1
  72. package/lib/mjs/relations.js +16 -1
  73. package/lib/mjs/relations.js.map +1 -1
  74. package/lib/mjs/snapshot.d.ts +12 -0
  75. package/lib/mjs/snapshot.d.ts.map +1 -1
  76. package/lib/mjs/snapshot.js +8 -0
  77. package/lib/mjs/snapshot.js.map +1 -1
  78. package/lib/mjs/statements.d.ts +11 -0
  79. package/lib/mjs/statements.d.ts.map +1 -1
  80. package/lib/mjs/statements.js +24 -0
  81. package/lib/mjs/statements.js.map +1 -1
  82. package/lib/mjs/subject-builder.d.ts +3 -2
  83. package/lib/mjs/subject-builder.d.ts.map +1 -1
  84. package/lib/mjs/subject-builder.js +10 -9
  85. package/lib/mjs/subject-builder.js.map +1 -1
  86. package/lib/mjs/subject-executor.d.ts +2 -2
  87. package/lib/mjs/subject-executor.d.ts.map +1 -1
  88. package/lib/mjs/subject-executor.js +11 -8
  89. package/lib/mjs/subject-executor.js.map +1 -1
  90. package/lib/mjs/subject.d.ts +8 -1
  91. package/lib/mjs/subject.d.ts.map +1 -1
  92. package/lib/mjs/subject.js.map +1 -1
  93. package/lib/tsconfig.cjs.tsbuildinfo +1 -1
  94. package/lib/tsconfig.mjs.tsbuildinfo +1 -1
  95. package/package.json +7 -7
@@ -5,7 +5,7 @@ import { RawQuery, UpdateQueryBuilder, TruncateTableQueryBuilder, SelectQueryBui
5
5
  import { Op } from './enums.js';
6
6
  import { Wrap } from './statements.js';
7
7
  import { OrmDriver } from './driver.js';
8
- import { IModelSnapshot } from './snapshot.js';
8
+ import { IModelChange, IModelSnapshot } from './snapshot.js';
9
9
  import { IContainer, Constructor } from '@spinajs/di';
10
10
  import { DateTime } from 'luxon';
11
11
  /**
@@ -18,22 +18,13 @@ import { DateTime } from 'luxon';
18
18
  */
19
19
  export declare function updateModelDescriptor(targetOrForward: any, callback: (descriptor: IModelDescriptor) => void): void;
20
20
  export declare class ModelBase<M = unknown> implements IModelBase {
21
- private __is_dirty__;
22
- /**
23
- * Marks model as dirty. It means that model have unsaved changes
24
- */
25
- get IsDirty(): boolean;
26
- set IsDirty(val: boolean);
27
21
  private _container;
28
22
  /**
29
- * prop to track model props that changeded since last update
30
- */
31
- private __dirty_props__;
32
- /**
33
- * Diff baseline, captured when this instance was hydrated from a database row.
34
- * `null` means "this model has never been in the database", which is what `save()`
35
- * uses to classify it as an INSERT — not the presence of a primary key, because
36
- * `setDefaults()` pre-fills @Uuid keys on construction.
23
+ * Diff baseline: a value copy of every persisted column, taken when the row was last read
24
+ * from or written to the database. `null` means the row has never been in the database, which
25
+ * is what classifies it as an INSERT - not the presence of a primary key, because
26
+ * `setDefaults()` pre-fills @Uuid keys on construction. Written only by `takeSnapshot()` and
27
+ * `clearSnapshot()`.
37
28
  */
38
29
  private __snapshot__;
39
30
  static readonly _queryScopes: QueryScope;
@@ -84,14 +75,45 @@ export declare class ModelBase<M = unknown> implements IModelBase {
84
75
  * dies. A relation's baseline is `snapshotRelation()`'s job, and it stores primary keys.
85
76
  */
86
77
  private snapshotColumns;
78
+ /**
79
+ * The value this model writes for every foreign key a @BelongsTo currently manages, keyed by
80
+ * column name. A relation holding a target owns its foreign key: `toSql()` writes the target's
81
+ * join-column value ( `Relation.PrimaryKey` — the target's primary key unless `@BelongsTo`
82
+ * names another column ), so a direct write to the column never reaches the database. A
83
+ * relation holding null or undefined owns nothing and is absent here, leaving the column to
84
+ * speak for itself: NULL after a `detach()`, untouched after a `populate()` that found no row.
85
+ *
86
+ * A @Recursive relation is excluded whatever it holds: `toSql()` writes its foreign key from
87
+ * the raw column, overriding the relation, so the column is what reaches the database.
88
+ *
89
+ * The single place that answers "what does this model persist for this column", so the
90
+ * snapshot baseline and the diff can never read the question differently.
91
+ */
92
+ private effectiveForeignKeys;
87
93
  /**
88
94
  * Captures the current value of every column as the diff baseline, discarding any
89
95
  * previous baseline and any relation keys recorded against it.
90
96
  *
97
+ * Reads the raw columns, deliberately: a snapshot is taken after an INSERT too, and an INSERT
98
+ * may omit a foreign key on purpose ( a deferred self-reference, whose target had no key yet ).
99
+ * Recording what the relation now holds would claim that key had been written and suppress the
100
+ * follow-up UPDATE that actually writes it. `writeBackRelationKeys()` is what brings a column
101
+ * in line with its relation, and it runs only where the key really was written.
102
+ *
91
103
  * Values are copied, never aliased — see `snapshotValue`. An aliased snapshot makes
92
104
  * every diff empty and `save()` a silent no-op.
93
105
  */
94
106
  takeSnapshot(): void;
107
+ /**
108
+ * Copies the value each @BelongsTo relation just wrote back onto its foreign-key column, so
109
+ * the model agrees with the row. Call it after a statement that wrote those keys, before
110
+ * `takeSnapshot()`.
111
+ *
112
+ * Without it a foreign key written directly and then overridden by its relation keeps the
113
+ * overridden value in the column, the snapshot records that value as the baseline, and the
114
+ * model reads dirty forever - every `save()` minting an UPDATE that changes nothing.
115
+ */
116
+ private writeBackRelationKeys;
95
117
  /**
96
118
  * Records the primary keys of the members currently in relation `name` as that
97
119
  * relation's baseline. A no-op when the model has no snapshot — an unhydrated model
@@ -105,49 +127,48 @@ export declare class ModelBase<M = unknown> implements IModelBase {
105
127
  */
106
128
  clearSnapshot(): void;
107
129
  /**
108
- * Names of the columns whose current value differs from the snapshot.
109
- *
110
- * With no snapshot every column is reported as changed, which is the right answer for a
111
- * model that is about to be inserted.
112
- *
113
- * This is deliberately independent of `__dirty_props__`: the proxy records a property as
114
- * dirty on any write, including one that puts the original value back, so the snapshot
115
- * diff is the more precise answer and the one the UPDATE payload is built from.
130
+ * `true` until the row has been in the database: the diff baseline is `null`. This is what
131
+ * classifies the model as an INSERT - not the presence of a primary key, because
132
+ * `setDefaults()` pre-fills @Uuid keys on construction.
133
+ */
134
+ get IsNew(): boolean;
135
+ /**
136
+ * Whether `save()` would write anything: a model that has never been in the database, or one
137
+ * with at least one column ( or re-pointed foreign key ) differing from its baseline.
116
138
  *
117
- * Reads the same column set `takeSnapshot()` wrote, and must keep doing so: comparing a column
118
- * the baseline never covered means comparing its live value against `undefined`, which reports it
119
- * changed on every single save.
139
+ * Derived from the snapshot on every read - there is no write observer - so it costs one
140
+ * comparison per column until the first difference. There is deliberately no setter: the only
141
+ * way to make a model clean is to persist it or to re-baseline it with `takeSnapshot()`.
120
142
  */
121
- changedColumns(): string[];
143
+ get IsDirty(): boolean;
122
144
  /**
123
- * Foreign-key columns a relation object reported as rewritten, via {@link markDirty}.
145
+ * Every persisted column whose current value differs from the baseline, in descriptor column
146
+ * order, followed by any @BelongsTo foreign key the descriptor declares no column for. On a
147
+ * model with no baseline every column is reported with `OldValue: undefined`.
124
148
  *
125
- * These are the only columns the snapshot diff cannot see. `SingleRelation.attach()` stores
126
- * the new target on the relation wrapper and marks the foreign key dirty, but never writes
127
- * the column on the model — the value is materialised from the relation later, by
128
- * `StandardModelToSqlConverter`. So `changedColumns()` compares the column against its
129
- * snapshot, finds it untouched, and reports no change even though the relation was
130
- * re-pointed. Detaching a relation and calling `update()` would then emit nothing at all.
149
+ * Computed on demand - nothing observes writes - so an in-place mutation of a JSON column is
150
+ * seen exactly like an assignment. Call it once and reuse the result rather than polling it
151
+ * in a loop.
131
152
  *
132
- * Restricted to declared relation foreign keys on purpose. `__dirty_props__` also collects
133
- * ordinary property writes, and folding those in wholesale would undo the precision the
134
- * diff exists for: a column written A -> B -> A is in `__dirty_props__` but has no net
135
- * change, and must not be written back.
153
+ * Named `changeSet` - not `changes` - because model members and columns share a namespace and
154
+ * `changes` is a real column name in downstream schemas.
136
155
  */
137
- protected relationDirtyColumns(): string[];
156
+ changeSet(): IModelChange[];
138
157
  /**
139
- * Records `prop` as changed and marks the model dirty.
140
- *
141
- * This is the supported way for relation objects to report that they rewrote one of the
142
- * owner's foreign keys. It replaces the `(owner as any).__dirty_props__.push(...)` casts
143
- * that reached into a private field from outside the class ( A6 ).
158
+ * The single diff. `stopAtFirst` lets a boolean question return as soon as one change is found.
144
159
  *
145
- * The push comes before `IsDirty = true` so the method stays correct even if the
146
- * `IsDirty` setter ever starts clearing `__dirty_props__` on a truthy assignment too.
160
+ * Every foreign key is resolved to ONE effective value before anything is compared, so
161
+ * `IsDirty` and `changeSet()` can never disagree and the short-circuit can never skip a
162
+ * decision the full diff would have made.
147
163
  *
148
- * @param prop - column name
164
+ * The rule: a @BelongsTo holding a target decides its foreign key, because that is what
165
+ * `toSql()` writes - the target's join-column value, `Relation.PrimaryKey`, which is the
166
+ * target's own primary key unless `@BelongsTo` names another column. A direct write to the
167
+ * column is therefore overridden and never reaches the database, and the diff has to say so.
168
+ * A relation holding null or undefined decides nothing and the column stands: NULL after a
169
+ * `detach()`, untouched after a `populate()` that found no row.
149
170
  */
150
- markDirty(prop: string): void;
171
+ private diff;
151
172
  valueOf(): any;
152
173
  driver(): OrmDriver;
153
174
  /**
@@ -328,11 +349,9 @@ export declare class ModelBase<M = unknown> implements IModelBase {
328
349
  /**
329
350
  * Writes the columns that differ from the snapshot.
330
351
  *
331
- * The change set comes from `changedColumns()` the snapshot diff and not from the
332
- * proxy's `__dirty_props__`, which records a property as dirty on ANY write including one
333
- * that puts the original value straight back. `save()` has always used the diff, and
334
- * `changedColumns()` documents it as the more precise answer; this path used the imprecise
335
- * one, so the same edit produced a different UPDATE depending on which method you called.
352
+ * The change set is `changeSet()` - the snapshot diff, which also covers a foreign key that was
353
+ * re-pointed through its relation - so re-assigning a column its current value produces no
354
+ * UPDATE, and a column written A -> B -> A is not written back.
336
355
  *
337
356
  * A model with no snapshot ( never hydrated ) reports every column as changed, which is the
338
357
  * right answer: there is no baseline to be more precise than.
@@ -1 +1 @@
1
- {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,yBAAyB,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAG/F,OAAO,EAAE,gBAAgB,EAAgB,eAAe,EAAkC,mBAAmB,EAAE,aAAa,EAAE,UAAU,EAAE,gBAAgB,EAA6C,UAAU,EAAqB,mBAAmB,EAAwB,iBAAiB,EAAuC,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC5X,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,kBAAkB,EAA4B,MAAM,eAAe,CAA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AAC,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAWnH,MAAM,CAAC,CAAC,SAAS,OAAO,SAAS,QAAQ,CAAC,aAAa,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAgBrH,MAAM,CAAC,CAAC,SAAS,OAAO,SAAS,QAAQ,CAAC,aAAa,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAgBrH,KAAK,CAAC,CAAC,SAAS,OAAO,SAAS,QAAQ,CAAC,aAAa,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC;IAa3G,WAAW,CAAC,CAAC,SAAS,OAAO,SAAS,QAAQ,CAAC,YAAY,CAAC,GAAG,EAAE,SAAS,KAAK,OAAO,CAAC,IAAI,CAAC;CAInG,CAAC;AAEF,eAAO,MAAM,kBAAkB,OAAQ,UAAU,SAAS,WAAW,CAAC,SAAS,CAAC,uBAE/E,CAAC"}
package/lib/cjs/model.js CHANGED
@@ -21,19 +21,6 @@ const lodash_1 = __importDefault(require("lodash"));
21
21
  const uuid_1 = require("uuid");
22
22
  const descriptor_js_1 = require("./descriptor.js");
23
23
  const primary_keys_js_1 = require("./primary-keys.js");
24
- const MODEL_PROXY_HANDLER = {
25
- set: (target, p, value) => {
26
- if (target[p] !== value) {
27
- target[p] = value;
28
- if (p !== 'IsDirty' && target.ModelDescriptor?.Columns.find((x) => x.Name === p)) {
29
- target.IsDirty = true;
30
- // HACK to access private prop ( internal use )
31
- target.__dirty_props__.push(p);
32
- }
33
- }
34
- return true;
35
- },
36
- };
37
24
  /**
38
25
  *
39
26
  * Updates model descriptor
@@ -59,18 +46,6 @@ function updateModelDescriptor(targetOrForward, callback) {
59
46
  callback(descriptor);
60
47
  }
61
48
  class ModelBase {
62
- /**
63
- * Marks model as dirty. It means that model have unsaved changes
64
- */
65
- get IsDirty() {
66
- return this.__is_dirty__;
67
- }
68
- set IsDirty(val) {
69
- this.__is_dirty__ = val;
70
- if (!val) {
71
- this.__dirty_props__ = [];
72
- }
73
- }
74
49
  /**
75
50
  * Gets descriptor for this model. It contains information about relations, orm driver, connection properties,
76
51
  * db table attached, column information and others.
@@ -161,10 +136,43 @@ class ModelBase {
161
136
  snapshotColumns() {
162
137
  return (this.ModelDescriptor?.Columns ?? []).filter((c) => !c.Virtual);
163
138
  }
139
+ /**
140
+ * The value this model writes for every foreign key a @BelongsTo currently manages, keyed by
141
+ * column name. A relation holding a target owns its foreign key: `toSql()` writes the target's
142
+ * join-column value ( `Relation.PrimaryKey` — the target's primary key unless `@BelongsTo`
143
+ * names another column ), so a direct write to the column never reaches the database. A
144
+ * relation holding null or undefined owns nothing and is absent here, leaving the column to
145
+ * speak for itself: NULL after a `detach()`, untouched after a `populate()` that found no row.
146
+ *
147
+ * A @Recursive relation is excluded whatever it holds: `toSql()` writes its foreign key from
148
+ * the raw column, overriding the relation, so the column is what reaches the database.
149
+ *
150
+ * The single place that answers "what does this model persist for this column", so the
151
+ * snapshot baseline and the diff can never read the question differently.
152
+ */
153
+ effectiveForeignKeys() {
154
+ const effective = new Map();
155
+ for (const [, r] of this.ModelDescriptor?.Relations ?? []) {
156
+ if (r.Type !== interfaces_js_1.RelationType.One || !r.ForeignKey || r.Recursive) {
157
+ continue;
158
+ }
159
+ const rel = this[r.Name];
160
+ if (rel?.Value) {
161
+ effective.set(r.ForeignKey, rel.Value[r.PrimaryKey]);
162
+ }
163
+ }
164
+ return effective;
165
+ }
164
166
  /**
165
167
  * Captures the current value of every column as the diff baseline, discarding any
166
168
  * previous baseline and any relation keys recorded against it.
167
169
  *
170
+ * Reads the raw columns, deliberately: a snapshot is taken after an INSERT too, and an INSERT
171
+ * may omit a foreign key on purpose ( a deferred self-reference, whose target had no key yet ).
172
+ * Recording what the relation now holds would claim that key had been written and suppress the
173
+ * follow-up UPDATE that actually writes it. `writeBackRelationKeys()` is what brings a column
174
+ * in line with its relation, and it runs only where the key really was written.
175
+ *
168
176
  * Values are copied, never aliased — see `snapshotValue`. An aliased snapshot makes
169
177
  * every diff empty and `save()` a silent no-op.
170
178
  */
@@ -175,6 +183,20 @@ class ModelBase {
175
183
  }
176
184
  this.__snapshot__ = snapshot;
177
185
  }
186
+ /**
187
+ * Copies the value each @BelongsTo relation just wrote back onto its foreign-key column, so
188
+ * the model agrees with the row. Call it after a statement that wrote those keys, before
189
+ * `takeSnapshot()`.
190
+ *
191
+ * Without it a foreign key written directly and then overridden by its relation keeps the
192
+ * overridden value in the column, the snapshot records that value as the baseline, and the
193
+ * model reads dirty forever - every `save()` minting an UPDATE that changes nothing.
194
+ */
195
+ writeBackRelationKeys() {
196
+ for (const [name, value] of this.effectiveForeignKeys()) {
197
+ this[name] = value;
198
+ }
199
+ }
178
200
  /**
179
201
  * Records the primary keys of the members currently in relation `name` as that
180
202
  * relation's baseline. A no-op when the model has no snapshot — an unhydrated model
@@ -206,72 +228,82 @@ class ModelBase {
206
228
  this.__snapshot__ = null;
207
229
  }
208
230
  /**
209
- * Names of the columns whose current value differs from the snapshot.
210
- *
211
- * With no snapshot every column is reported as changed, which is the right answer for a
212
- * model that is about to be inserted.
213
- *
214
- * This is deliberately independent of `__dirty_props__`: the proxy records a property as
215
- * dirty on any write, including one that puts the original value back, so the snapshot
216
- * diff is the more precise answer and the one the UPDATE payload is built from.
231
+ * `true` until the row has been in the database: the diff baseline is `null`. This is what
232
+ * classifies the model as an INSERT - not the presence of a primary key, because
233
+ * `setDefaults()` pre-fills @Uuid keys on construction.
234
+ */
235
+ get IsNew() {
236
+ return this.__snapshot__ === null;
237
+ }
238
+ /**
239
+ * Whether `save()` would write anything: a model that has never been in the database, or one
240
+ * with at least one column ( or re-pointed foreign key ) differing from its baseline.
217
241
  *
218
- * Reads the same column set `takeSnapshot()` wrote, and must keep doing so: comparing a column
219
- * the baseline never covered means comparing its live value against `undefined`, which reports it
220
- * changed on every single save.
242
+ * Derived from the snapshot on every read - there is no write observer - so it costs one
243
+ * comparison per column until the first difference. There is deliberately no setter: the only
244
+ * way to make a model clean is to persist it or to re-baseline it with `takeSnapshot()`.
221
245
  */
222
- changedColumns() {
223
- const columns = this.snapshotColumns();
224
- if (!this.__snapshot__) {
225
- return columns.map((c) => c.Name);
226
- }
227
- const snapshot = this.__snapshot__;
228
- return columns.filter((c) => !(0, snapshot_js_1.snapshotEquals)(snapshot.Columns.get(c.Name), this[c.Name], c.Converter)).map((c) => c.Name);
246
+ get IsDirty() {
247
+ return this.IsNew || this.diff(true).length > 0;
229
248
  }
230
249
  /**
231
- * Foreign-key columns a relation object reported as rewritten, via {@link markDirty}.
250
+ * Every persisted column whose current value differs from the baseline, in descriptor column
251
+ * order, followed by any @BelongsTo foreign key the descriptor declares no column for. On a
252
+ * model with no baseline every column is reported with `OldValue: undefined`.
232
253
  *
233
- * These are the only columns the snapshot diff cannot see. `SingleRelation.attach()` stores
234
- * the new target on the relation wrapper and marks the foreign key dirty, but never writes
235
- * the column on the model — the value is materialised from the relation later, by
236
- * `StandardModelToSqlConverter`. So `changedColumns()` compares the column against its
237
- * snapshot, finds it untouched, and reports no change even though the relation was
238
- * re-pointed. Detaching a relation and calling `update()` would then emit nothing at all.
254
+ * Computed on demand - nothing observes writes - so an in-place mutation of a JSON column is
255
+ * seen exactly like an assignment. Call it once and reuse the result rather than polling it
256
+ * in a loop.
239
257
  *
240
- * Restricted to declared relation foreign keys on purpose. `__dirty_props__` also collects
241
- * ordinary property writes, and folding those in wholesale would undo the precision the
242
- * diff exists for: a column written A -> B -> A is in `__dirty_props__` but has no net
243
- * change, and must not be written back.
258
+ * Named `changeSet` - not `changes` - because model members and columns share a namespace and
259
+ * `changes` is a real column name in downstream schemas.
244
260
  */
245
- relationDirtyColumns() {
246
- const descriptor = this.ModelDescriptor;
247
- if (!descriptor) {
248
- return [];
249
- }
250
- const relationKeys = new Set();
251
- for (const [, relation] of descriptor.Relations) {
252
- if (relation.ForeignKey) {
253
- relationKeys.add(relation.ForeignKey);
254
- }
255
- }
256
- return this.__dirty_props__.filter((p) => relationKeys.has(p));
261
+ changeSet() {
262
+ return this.diff(false);
257
263
  }
258
264
  /**
259
- * Records `prop` as changed and marks the model dirty.
265
+ * The single diff. `stopAtFirst` lets a boolean question return as soon as one change is found.
260
266
  *
261
- * This is the supported way for relation objects to report that they rewrote one of the
262
- * owner's foreign keys. It replaces the `(owner as any).__dirty_props__.push(...)` casts
263
- * that reached into a private field from outside the class ( A6 ).
267
+ * Every foreign key is resolved to ONE effective value before anything is compared, so
268
+ * `IsDirty` and `changeSet()` can never disagree and the short-circuit can never skip a
269
+ * decision the full diff would have made.
264
270
  *
265
- * The push comes before `IsDirty = true` so the method stays correct even if the
266
- * `IsDirty` setter ever starts clearing `__dirty_props__` on a truthy assignment too.
267
- *
268
- * @param prop - column name
271
+ * The rule: a @BelongsTo holding a target decides its foreign key, because that is what
272
+ * `toSql()` writes - the target's join-column value, `Relation.PrimaryKey`, which is the
273
+ * target's own primary key unless `@BelongsTo` names another column. A direct write to the
274
+ * column is therefore overridden and never reaches the database, and the diff has to say so.
275
+ * A relation holding null or undefined decides nothing and the column stands: NULL after a
276
+ * `detach()`, untouched after a `populate()` that found no row.
269
277
  */
270
- markDirty(prop) {
271
- if (!this.__dirty_props__.includes(prop)) {
272
- this.__dirty_props__.push(prop);
278
+ diff(stopAtFirst) {
279
+ const columns = this.snapshotColumns();
280
+ const snap = this.__snapshot__?.Columns;
281
+ const out = [];
282
+ const effective = this.effectiveForeignKeys();
283
+ for (const c of columns) {
284
+ const current = effective.has(c.Name) ? effective.get(c.Name) : this[c.Name];
285
+ if (!snap || !(0, snapshot_js_1.snapshotEquals)(snap.get(c.Name), current, c.Converter)) {
286
+ out.push({ Column: c.Name, OldValue: (0, snapshot_js_1.baselineValue)(snap?.get(c.Name)), NewValue: current });
287
+ if (stopAtFirst) {
288
+ return out;
289
+ }
290
+ }
291
+ }
292
+ // A relation-managed foreign key the descriptor has no column for - the loop above never
293
+ // saw it, and there is no converter to compare it through.
294
+ const declared = new Set(columns.map((c) => c.Name));
295
+ for (const [name, current] of effective) {
296
+ if (declared.has(name)) {
297
+ continue;
298
+ }
299
+ if (!snap || !(0, snapshot_js_1.snapshotEquals)(snap.get(name), current)) {
300
+ out.push({ Column: name, OldValue: (0, snapshot_js_1.baselineValue)(snap?.get(name)), NewValue: current });
301
+ if (stopAtFirst) {
302
+ return out;
303
+ }
304
+ }
273
305
  }
274
- this.IsDirty = true;
306
+ return out;
275
307
  }
276
308
  valueOf() {
277
309
  return this.PrimaryKeyValue;
@@ -458,23 +490,18 @@ class ModelBase {
458
490
  throw new Error('Not implemented');
459
491
  }
460
492
  constructor(data) {
461
- this.__is_dirty__ = false;
462
493
  /**
463
- * prop to track model props that changeded since last update
464
- */
465
- this.__dirty_props__ = [];
466
- /**
467
- * Diff baseline, captured when this instance was hydrated from a database row.
468
- * `null` means "this model has never been in the database", which is what `save()`
469
- * uses to classify it as an INSERT — not the presence of a primary key, because
470
- * `setDefaults()` pre-fills @Uuid keys on construction.
494
+ * Diff baseline: a value copy of every persisted column, taken when the row was last read
495
+ * from or written to the database. `null` means the row has never been in the database, which
496
+ * is what classifies it as an INSERT - not the presence of a primary key, because
497
+ * `setDefaults()` pre-fills @Uuid keys on construction. Written only by `takeSnapshot()` and
498
+ * `clearSnapshot()`.
471
499
  */
472
500
  this.__snapshot__ = null;
473
501
  this.setDefaults();
474
502
  if (data) {
475
503
  this.hydrate(data);
476
504
  }
477
- return new Proxy(this, MODEL_PROXY_HANDLER);
478
505
  }
479
506
  /**
480
507
  * Fills model with data. It only fills properties that exists in database
@@ -503,7 +530,6 @@ class ModelBase {
503
530
  switch (v.Type) {
504
531
  case interfaces_js_1.RelationType.One:
505
532
  this[v.Name].attach(data);
506
- this.markDirty(v.ForeignKey);
507
533
  break;
508
534
  case interfaces_js_1.RelationType.Many: {
509
535
  // Set the child's back-reference to this owner, when the child declares one.
@@ -525,7 +551,6 @@ class ModelBase {
525
551
  break;
526
552
  }
527
553
  }
528
- this.IsDirty = true;
529
554
  }
530
555
  /**
531
556
  * Extracts all data from model. It takes only properties that exists in DB
@@ -555,7 +580,7 @@ class ModelBase {
555
580
  toSql(onlyDirty) {
556
581
  const vals = this.Container.resolve(interfaces_js_1.ModelToSqlConverter).toSql(this);
557
582
  if (onlyDirty) {
558
- return lodash_1.default.pick(vals, this.__dirty_props__);
583
+ return lodash_1.default.pick(vals, this.changeSet().map((c) => c.Column));
559
584
  }
560
585
  return vals;
561
586
  }
@@ -571,7 +596,6 @@ class ModelBase {
571
596
  return;
572
597
  }
573
598
  const result = await this.constructor.destroy(pk);
574
- this.IsDirty = false;
575
599
  return result;
576
600
  }
577
601
  /**
@@ -587,16 +611,18 @@ class ModelBase {
587
611
  const { query } = this.createUpdateQuery();
588
612
  query.update(this.toSql());
589
613
  (0, primary_keys_js_1.wherePk)(query, this.ModelDescriptor, this.PrimaryKeyValue);
590
- return await query;
614
+ const result = await query;
615
+ // The whole model is in the database now - that is the baseline for the next update().
616
+ this.writeBackRelationKeys();
617
+ this.takeSnapshot();
618
+ return result;
591
619
  }
592
620
  /**
593
621
  * Writes the columns that differ from the snapshot.
594
622
  *
595
- * The change set comes from `changedColumns()` the snapshot diff and not from the
596
- * proxy's `__dirty_props__`, which records a property as dirty on ANY write including one
597
- * that puts the original value straight back. `save()` has always used the diff, and
598
- * `changedColumns()` documents it as the more precise answer; this path used the imprecise
599
- * one, so the same edit produced a different UPDATE depending on which method you called.
623
+ * The change set is `changeSet()` - the snapshot diff, which also covers a foreign key that was
624
+ * re-pointed through its relation - so re-assigning a column its current value produces no
625
+ * UPDATE, and a column written A -> B -> A is not written back.
600
626
  *
601
627
  * A model with no snapshot ( never hydrated ) reports every column as changed, which is the
602
628
  * right answer: there is no baseline to be more precise than.
@@ -612,11 +638,12 @@ class ModelBase {
612
638
  this.hydrate(data);
613
639
  }
614
640
  const keyColumns = this.ModelDescriptor.PrimaryKey ?? [];
615
- const changed = lodash_1.default.union(this.changedColumns(), this.relationDirtyColumns()).filter((c) => !keyColumns.includes(c));
641
+ const changed = this.changeSet()
642
+ .map((c) => c.Column)
643
+ .filter((c) => !keyColumns.includes(c));
616
644
  // Nothing to write. Checked against the diff, so re-assigning a column its current value
617
645
  // no longer produces an UPDATE that sets it to what it already was.
618
646
  if (changed.length === 0) {
619
- this.IsDirty = false;
620
647
  return result;
621
648
  }
622
649
  const updatedAt = this.ModelDescriptor.Timestamps.UpdatedAt;
@@ -630,7 +657,7 @@ class ModelBase {
630
657
  query.update(lodash_1.default.pick(this.toSql(), changed));
631
658
  (0, primary_keys_js_1.wherePk)(query, this.ModelDescriptor, this.PrimaryKeyValue);
632
659
  const updateResult = await query;
633
- this.IsDirty = false;
660
+ this.writeBackRelationKeys();
634
661
  this.takeSnapshot();
635
662
  return updateResult;
636
663
  }
@@ -683,8 +710,12 @@ class ModelBase {
683
710
  modelCreation: () => null,
684
711
  afterHydration: () => null,
685
712
  });
686
- const result = query.values(this.toSql());
687
- this.IsDirty = false;
713
+ // Awaited here, not by the caller: the afterQuery middleware above backfills a generated key
714
+ // during execution, and the snapshot must include it. Taken only after the await - a throw
715
+ // leaves the model exactly as dirty as it was.
716
+ const result = await query.values(this.toSql());
717
+ this.writeBackRelationKeys();
718
+ this.takeSnapshot();
688
719
  return result;
689
720
  }
690
721
  /**
@@ -746,7 +777,9 @@ class ModelBase {
746
777
  for (const c of this.ModelDescriptor.Columns) {
747
778
  this[c.Name] = model[c.Name];
748
779
  }
749
- this.IsDirty = false;
780
+ // Every column now holds what the database holds - that is the new baseline, not the one
781
+ // captured before the refresh.
782
+ this.takeSnapshot();
750
783
  }
751
784
  toJSON() {
752
785
  return this.dehydrate();
@@ -1113,6 +1146,24 @@ exports.MODEL_STATIC_MIXINS = {
1113
1146
  // supplied and generated keys, a statement the server did not insert one row per input
1114
1147
  // row for — cannot be mapped positionally, so nothing is assigned. Callers needing the
1115
1148
  // keys there must re-select or insert the models one at a time.
1149
+ // Every persist path re-baselines after its statement, and the baseline is taken after
1150
+ // the backfill above so it carries whatever key the statement produced: the model is
1151
+ // re-baselined to exactly what the statement wrote, no more. The relation keys are
1152
+ // written back first because the payload took them from the relation ( `toSql()` reads
1153
+ // the target's join column ) and not from the model's own foreign-key column - without
1154
+ // the write-back the baseline would record a column value the row does not hold, and the
1155
+ // model would read dirty right after a successful insert.
1156
+ //
1157
+ // A plain-object payload is not a model and has nothing to snapshot; a model whose key
1158
+ // could not be mapped positionally is still in the database, so it is re-baselined too -
1159
+ // it just carries no key, and cannot be updated through this instance until one is set.
1160
+ rows.forEach((v) => {
1161
+ if (v instanceof ModelBase) {
1162
+ // Private instance member - the static side of the class cannot see it.
1163
+ v.writeBackRelationKeys();
1164
+ v.takeSnapshot();
1165
+ }
1166
+ });
1116
1167
  return result;
1117
1168
  },
1118
1169
  modelCreation: () => null,