@proteinjs/db 1.21.8 → 1.21.9
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/CHANGELOG.md +11 -0
- package/LICENSE +21 -0
- package/dist/generated/index.js +5 -5
- package/dist/generated/index.js.map +1 -1
- package/dist/generated/test/index.js +1 -1
- package/dist/generated/test/index.js.map +1 -1
- package/dist/src/source/SourceRecordLoader.d.ts +28 -7
- package/dist/src/source/SourceRecordLoader.d.ts.map +1 -1
- package/dist/src/source/SourceRecordLoader.js +79 -48
- package/dist/src/source/SourceRecordLoader.js.map +1 -1
- package/dist/test/SourceRecordLoader.test.d.ts +2 -0
- package/dist/test/SourceRecordLoader.test.d.ts.map +1 -0
- package/dist/test/SourceRecordLoader.test.js +121 -0
- package/dist/test/SourceRecordLoader.test.js.map +1 -0
- package/dist/test/reusable/CascadeDeleteTests.js +2 -2
- package/dist/test/reusable/ColumnTypesTests.js +2 -2
- package/dist/test/reusable/CrudTests.js +3 -3
- package/dist/test/reusable/DynamicReferenceColumnTests.js +2 -2
- package/dist/test/reusable/TableManagerTests.js +2 -2
- package/dist/test/reusable/TransactionTests.js +2 -2
- package/generated/index.ts +17 -20
- package/generated/test/index.ts +39 -42
- package/package.json +3 -2
- package/src/source/SourceRecordLoader.ts +73 -42
- package/test/SourceRecordLoader.test.ts +154 -0
- package/test/reusable/CascadeDeleteTests.ts +2 -2
- package/test/reusable/ColumnTypesTests.ts +2 -2
- package/test/reusable/CrudTests.ts +3 -3
- package/test/reusable/DynamicReferenceColumnTests.ts +2 -2
- package/test/reusable/TableManagerTests.ts +2 -2
- package/test/reusable/TransactionTests.ts +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../generated/test/index.ts"],"names":[],"mappings":";AAAA,oCAAoC;;;;;;;;;;;;;;;;AAEpC,+BAA6B;AAC7B,6BAA2B;AAC3B,iCAA+B;AAC/B,iCAA+B;AAC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yBAAyB,EAAE,mCAAS;IACpC,4BAA4B,EAAE,sCAAY;IAC1C,iCAAiC,EAAE,2CAAiB;IACpD,gCAAgC,EAAE,2CAAgB;IAClD,2BAA2B,EAAE,sCAAW;IACxC,yBAAyB,EAAE,oCAAS;IACpC,yBAAyB,EAAE,iCAAS;IACpC,iCAAiC,EAAE,kCAAiB;IACpD,qCAAqC,EAAE,sCAAqB;IAC5D,sCAAsC,EAAE,yDAAsB;IAC9D,6BAA6B,EAAE,gDAAa;IAC5C,6BAA6B,EAAE,gDAAa;IAC5C,mCAAmC,EAAE,sDAAmB;IACxD,6BAA6B,EAAE,sCAAa;IAC5C,oCAAoC,EAAE,6CAAoB;IAC1D,gCAAgC,EAAE,yCAAgB;IAClD,4CAA4C,EAAE,oDAA4B;IAC1E,gDAAgD,EAAE,wDAAgC;IAClF,kBAAkB,EAAE,OAAE;IACtB,iCAAiC,EAAE,qCAAiB;IACpD,+BAA+B,EAAE,iCAAe;IAChD,yBAAyB,EAAE,qBAAS;IACpC,8BAA8B,EAAE,+BAAc;IAC9C,wCAAwC,EAAE,mDAAwB;IAClE,mCAAmC,EAAE,yCAAmB;IACxD,+BAA+B,EAAE,iCAAe;IAChD,kCAAkC,EAAE,uCAAkB;IACtD,8BAA8B,EAAE,+BAAc;IAC9C,iCAAiC,EAAE,qCAAiB;CACpD,CAAC;AAGF,kCAAkC;AAElC,oDAAyD;AACzD,6BAAgB,CAAC,KAAK,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;AAGjD,mDAAiC"}
|
|
@@ -4,21 +4,42 @@ export declare class SourceRecordLoader {
|
|
|
4
4
|
/**
|
|
5
5
|
* Compare source record fields against the existing DB record to detect actual changes.
|
|
6
6
|
* Only fields present on the source record are compared (ignoring `created`, `updated`).
|
|
7
|
-
* Uses serialization to normalize values (e.g. Reference objects, Moment, JSON) before
|
|
7
|
+
* Uses serialization to normalize values (e.g. Reference objects, Moment, JSON) before
|
|
8
|
+
* comparison, then delegates to {@link findMismatchPath}.
|
|
8
9
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
10
|
+
* Object-valued fields (e.g. `JsonColumn` blobs) are treated as source-authoritative:
|
|
11
|
+
* any structural drift, including extra keys left behind by earlier source versions,
|
|
12
|
+
* triggers a rewrite. Primitive columns retain their existing semantics.
|
|
12
13
|
*/
|
|
13
14
|
private hasChanges;
|
|
15
|
+
private getSourceRecordsMap;
|
|
14
16
|
/**
|
|
15
17
|
* Find the first point of divergence between source and existing values.
|
|
16
18
|
* Returns a description of the mismatch path, or null if they match.
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
+
*
|
|
20
|
+
* For object-valued fields (e.g. a `JsonColumn` blob), source is treated as
|
|
21
|
+
* fully authoritative: any structural drift — extra keys in existing, missing
|
|
22
|
+
* keys in existing, or value differences anywhere in the subtree — produces
|
|
23
|
+
* a mismatch. Comparison goes through {@link SourceRecordLoader.canonicalStringify}
|
|
24
|
+
* so that key ordering (which backing stores may canonicalize alphabetically)
|
|
25
|
+
* does not cause false positives.
|
|
26
|
+
*
|
|
19
27
|
* For arrays, order and length must match exactly.
|
|
20
28
|
*/
|
|
21
29
|
private findMismatchPath;
|
|
22
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Canonical JSON stringification with recursively sorted object keys.
|
|
32
|
+
*
|
|
33
|
+
* Why this exists: some stores (notably Spanner) canonicalize JSON object
|
|
34
|
+
* keys alphabetically on storage. Source records declared in TypeScript
|
|
35
|
+
* code don't guarantee alphabetical key order, so a plain `JSON.stringify`
|
|
36
|
+
* comparison between source and the existing DB value would produce false
|
|
37
|
+
* mismatches driven purely by key ordering. Sorting keys on both sides
|
|
38
|
+
* normalizes them so semantic equality maps to string equality.
|
|
39
|
+
*
|
|
40
|
+
* Arrays preserve order (order is semantic for arrays); only object keys
|
|
41
|
+
* are sorted.
|
|
42
|
+
*/
|
|
43
|
+
private canonicalStringify;
|
|
23
44
|
}
|
|
24
45
|
//# sourceMappingURL=SourceRecordLoader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SourceRecordLoader.d.ts","sourceRoot":"","sources":["../../../src/source/SourceRecordLoader.ts"],"names":[],"mappings":"AAYA,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,MAAM,CAA+C;IAEvD,IAAI;IAmDV
|
|
1
|
+
{"version":3,"file":"SourceRecordLoader.d.ts","sourceRoot":"","sources":["../../../src/source/SourceRecordLoader.ts"],"names":[],"mappings":"AAYA,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,MAAM,CAA+C;IAEvD,IAAI;IAmDV;;;;;;;;;OASG;YACW,UAAU;YAmBV,mBAAmB;IA0BjC;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,gBAAgB;IAkDxB;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,kBAAkB;CAkB3B"}
|
|
@@ -151,11 +151,12 @@ var SourceRecordLoader = /** @class */ (function () {
|
|
|
151
151
|
/**
|
|
152
152
|
* Compare source record fields against the existing DB record to detect actual changes.
|
|
153
153
|
* Only fields present on the source record are compared (ignoring `created`, `updated`).
|
|
154
|
-
* Uses serialization to normalize values (e.g. Reference objects, Moment, JSON) before
|
|
154
|
+
* Uses serialization to normalize values (e.g. Reference objects, Moment, JSON) before
|
|
155
|
+
* comparison, then delegates to {@link findMismatchPath}.
|
|
155
156
|
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
157
|
+
* Object-valued fields (e.g. `JsonColumn` blobs) are treated as source-authoritative:
|
|
158
|
+
* any structural drift, including extra keys left behind by earlier source versions,
|
|
159
|
+
* triggers a rewrite. Primitive columns retain their existing semantics.
|
|
159
160
|
*/
|
|
160
161
|
SourceRecordLoader.prototype.hasChanges = function (table, sourceRecord, existingRecord) {
|
|
161
162
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -185,11 +186,46 @@ var SourceRecordLoader = /** @class */ (function () {
|
|
|
185
186
|
});
|
|
186
187
|
});
|
|
187
188
|
};
|
|
189
|
+
SourceRecordLoader.prototype.getSourceRecordsMap = function () {
|
|
190
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
191
|
+
var sourceRecordsMap, sourceRecordTables, _i, sourceRecordTables_1, sourceRecordTable, sourceRecordLoaders, _a, sourceRecordLoaders_1, sourceRecordLoader;
|
|
192
|
+
return __generator(this, function (_b) {
|
|
193
|
+
sourceRecordsMap = {};
|
|
194
|
+
sourceRecordTables = (0, SourceRecord_1.getSourceRecordTables)();
|
|
195
|
+
for (_i = 0, sourceRecordTables_1 = sourceRecordTables; _i < sourceRecordTables_1.length; _i++) {
|
|
196
|
+
sourceRecordTable = sourceRecordTables_1[_i];
|
|
197
|
+
if (!sourceRecordsMap[sourceRecordTable.name]) {
|
|
198
|
+
sourceRecordsMap[sourceRecordTable.name] = { table: sourceRecordTable, records: [], recordIds: [] };
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
sourceRecordLoaders = (0, SourceRecord_1.getSourceRecordLoaders)();
|
|
202
|
+
for (_a = 0, sourceRecordLoaders_1 = sourceRecordLoaders; _a < sourceRecordLoaders_1.length; _a++) {
|
|
203
|
+
sourceRecordLoader = sourceRecordLoaders_1[_a];
|
|
204
|
+
if (!sourceRecordsMap[sourceRecordLoader.table.name]) {
|
|
205
|
+
sourceRecordsMap[sourceRecordLoader.table.name] = {
|
|
206
|
+
table: sourceRecordLoader.table,
|
|
207
|
+
records: [],
|
|
208
|
+
recordIds: [],
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
sourceRecordsMap[sourceRecordLoader.table.name].records.push(sourceRecordLoader.record);
|
|
212
|
+
sourceRecordsMap[sourceRecordLoader.table.name].recordIds.push(sourceRecordLoader.record.id);
|
|
213
|
+
}
|
|
214
|
+
return [2 /*return*/, sourceRecordsMap];
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
};
|
|
188
218
|
/**
|
|
189
219
|
* Find the first point of divergence between source and existing values.
|
|
190
220
|
* Returns a description of the mismatch path, or null if they match.
|
|
191
|
-
*
|
|
192
|
-
*
|
|
221
|
+
*
|
|
222
|
+
* For object-valued fields (e.g. a `JsonColumn` blob), source is treated as
|
|
223
|
+
* fully authoritative: any structural drift — extra keys in existing, missing
|
|
224
|
+
* keys in existing, or value differences anywhere in the subtree — produces
|
|
225
|
+
* a mismatch. Comparison goes through {@link SourceRecordLoader.canonicalStringify}
|
|
226
|
+
* so that key ordering (which backing stores may canonicalize alphabetically)
|
|
227
|
+
* does not cause false positives.
|
|
228
|
+
*
|
|
193
229
|
* For arrays, order and length must match exactly.
|
|
194
230
|
*/
|
|
195
231
|
SourceRecordLoader.prototype.findMismatchPath = function (source, existing, path) {
|
|
@@ -225,51 +261,46 @@ var SourceRecordLoader = /** @class */ (function () {
|
|
|
225
261
|
}
|
|
226
262
|
return null;
|
|
227
263
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
}
|
|
235
|
-
if (!(key in existing)) {
|
|
236
|
-
return "".concat(path, ".").concat(key, ": key missing in existing");
|
|
237
|
-
}
|
|
238
|
-
var result = this.findMismatchPath(source[key], existing[key], "".concat(path, ".").concat(key));
|
|
239
|
-
if (result) {
|
|
240
|
-
return result;
|
|
241
|
-
}
|
|
264
|
+
// Both values are non-null, non-array objects. Treat source as authoritative:
|
|
265
|
+
// any structural drift triggers a mismatch. Canonical stringify normalizes
|
|
266
|
+
// key order so storage-side canonicalization (e.g. Spanner alphabetizes JSON
|
|
267
|
+
// keys) doesn't register as drift.
|
|
268
|
+
if (this.canonicalStringify(source) !== this.canonicalStringify(existing)) {
|
|
269
|
+
return "".concat(path, ": object differs");
|
|
242
270
|
}
|
|
243
271
|
return null;
|
|
244
272
|
};
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
+
/**
|
|
274
|
+
* Canonical JSON stringification with recursively sorted object keys.
|
|
275
|
+
*
|
|
276
|
+
* Why this exists: some stores (notably Spanner) canonicalize JSON object
|
|
277
|
+
* keys alphabetically on storage. Source records declared in TypeScript
|
|
278
|
+
* code don't guarantee alphabetical key order, so a plain `JSON.stringify`
|
|
279
|
+
* comparison between source and the existing DB value would produce false
|
|
280
|
+
* mismatches driven purely by key ordering. Sorting keys on both sides
|
|
281
|
+
* normalizes them so semantic equality maps to string equality.
|
|
282
|
+
*
|
|
283
|
+
* Arrays preserve order (order is semantic for arrays); only object keys
|
|
284
|
+
* are sorted.
|
|
285
|
+
*/
|
|
286
|
+
SourceRecordLoader.prototype.canonicalStringify = function (value) {
|
|
287
|
+
var _this = this;
|
|
288
|
+
if (value === null || typeof value !== 'object') {
|
|
289
|
+
return JSON.stringify(value);
|
|
290
|
+
}
|
|
291
|
+
if (Array.isArray(value)) {
|
|
292
|
+
// Mirror JSON.stringify: undefined array elements serialize as `null`.
|
|
293
|
+
return '[' + value.map(function (v) { return (v === undefined ? 'null' : _this.canonicalStringify(v)); }).join(',') + ']';
|
|
294
|
+
}
|
|
295
|
+
// Mirror JSON.stringify: skip object properties whose value is `undefined`.
|
|
296
|
+
// This keeps source records that declare optional fields (as `undefined`)
|
|
297
|
+
// from being treated as drift vs existing rows that simply don't have the
|
|
298
|
+
// field — `undefined` would never have been written to the DB.
|
|
299
|
+
var obj = value;
|
|
300
|
+
var keys = Object.keys(obj)
|
|
301
|
+
.filter(function (k) { return obj[k] !== undefined; })
|
|
302
|
+
.sort();
|
|
303
|
+
return '{' + keys.map(function (k) { return JSON.stringify(k) + ':' + _this.canonicalStringify(obj[k]); }).join(',') + '}';
|
|
273
304
|
};
|
|
274
305
|
return SourceRecordLoader;
|
|
275
306
|
}());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SourceRecordLoader.js","sourceRoot":"","sources":["../../../src/source/SourceRecordLoader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAA2C;AAC3C,gDAAmD;AACnD,+CAA6F;AAE7F,4BAAsC;AACtC,uDAAsD;AACtD,oCAA6C;AAM7C;IAAA;QACU,WAAM,GAAG,IAAI,eAAM,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"SourceRecordLoader.js","sourceRoot":"","sources":["../../../src/source/SourceRecordLoader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAA2C;AAC3C,gDAAmD;AACnD,+CAA6F;AAE7F,4BAAsC;AACtC,uDAAsD;AACtD,oCAA6C;AAM7C;IAAA;QACU,WAAM,GAAG,IAAI,eAAM,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC;IA0M/D,CAAC;IAxMO,iCAAI,GAAV;;;;;4BAC2B,qBAAM,IAAI,CAAC,mBAAmB,EAAE,EAAA;;wBAAnD,gBAAgB,GAAG,SAAgC;wBACnD,EAAE,GAAG,IAAA,kBAAa,GAAE,CAAC;6BACH,gBAAgB;;;;;;;;;;;wBAClC,WAAW,GAAG,CAAC,CAAC;wBAChB,WAAW,GAAG,CAAC,CAAC;wBAChB,cAAc,GAAG,CAAC,CAAC;wBACnB,WAAW,GAAG,CAAC,CAAC;wBACd,KAAK,GAAG,gBAAgB,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC;wBAC1C,eAAe,GAAG,gBAAg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AvD,CAAuD,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;SACxG;QACD,4EAA4E;QAC5E,0EAA0E;QAC1E,0EAA0E;QAC1E,+DAA+D;QAC/D,IAAM,GAAG,GAAG,KAAgC,CAAC;QAC7C,IAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;aAC1B,MAAM,CAAC,UAAC,CAAC,IAAK,OAAA,GAAG,CAAC,CAAC,CAAC,KAAK,SAAS,EAApB,CAAoB,CAAC;aACnC,IAAI,EAAE,CAAC;QACV,OAAO,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,UAAC,CAAC,IAAK,OAAA,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,KAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAzD,CAAyD,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;IAC1G,CAAC;IACH,yBAAC;AAAD,CAAC,AA3MD,IA2MC;AA3MY,gDAAkB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SourceRecordLoader.test.d.ts","sourceRoot":"","sources":["../../test/SourceRecordLoader.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var SourceRecordLoader_1 = require("../src/source/SourceRecordLoader");
|
|
4
|
+
var internals = function () { return new SourceRecordLoader_1.SourceRecordLoader(); };
|
|
5
|
+
describe('SourceRecordLoader.canonicalStringify', function () {
|
|
6
|
+
it('produces the same string for objects with different key orders', function () {
|
|
7
|
+
var loader = internals();
|
|
8
|
+
var a = { foo: 1, bar: 2, baz: 3 };
|
|
9
|
+
var b = { baz: 3, foo: 1, bar: 2 };
|
|
10
|
+
expect(loader.canonicalStringify(a)).toBe(loader.canonicalStringify(b));
|
|
11
|
+
});
|
|
12
|
+
it('sorts keys alphabetically in nested objects', function () {
|
|
13
|
+
var loader = internals();
|
|
14
|
+
var value = { z: { c: 1, a: 2, b: 3 }, a: 1 };
|
|
15
|
+
expect(loader.canonicalStringify(value)).toBe('{"a":1,"z":{"a":2,"b":3,"c":1}}');
|
|
16
|
+
});
|
|
17
|
+
it('preserves array order (arrays are semantically ordered)', function () {
|
|
18
|
+
var loader = internals();
|
|
19
|
+
expect(loader.canonicalStringify([3, 1, 2])).toBe('[3,1,2]');
|
|
20
|
+
});
|
|
21
|
+
it('handles primitives the same as JSON.stringify', function () {
|
|
22
|
+
var loader = internals();
|
|
23
|
+
expect(loader.canonicalStringify('hello')).toBe('"hello"');
|
|
24
|
+
expect(loader.canonicalStringify(42)).toBe('42');
|
|
25
|
+
expect(loader.canonicalStringify(true)).toBe('true');
|
|
26
|
+
expect(loader.canonicalStringify(null)).toBe('null');
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
describe('SourceRecordLoader.findMismatchPath', function () {
|
|
30
|
+
describe('object comparison', function () {
|
|
31
|
+
it('returns null for identical objects', function () {
|
|
32
|
+
var loader = internals();
|
|
33
|
+
var source = { content: '', type: 'body1', linkedThoughtId: '' };
|
|
34
|
+
var existing = { content: '', type: 'body1', linkedThoughtId: '' };
|
|
35
|
+
expect(loader.findMismatchPath(source, existing, 'newThoughtTemplate')).toBeNull();
|
|
36
|
+
});
|
|
37
|
+
it('returns null when existing has the same keys in a different order (Spanner alphabetizes)', function () {
|
|
38
|
+
// This is the critical case: Spanner canonicalizes JSON object keys
|
|
39
|
+
// alphabetically on storage. Source declared in TypeScript doesn't
|
|
40
|
+
// guarantee alphabetical key order. The two must still compare equal.
|
|
41
|
+
var loader = internals();
|
|
42
|
+
var source = { content: '', type: 'body1', linkedThoughtId: '' };
|
|
43
|
+
var existing = { content: '', linkedThoughtId: '', type: 'body1' };
|
|
44
|
+
expect(loader.findMismatchPath(source, existing, 'newThoughtTemplate')).toBeNull();
|
|
45
|
+
});
|
|
46
|
+
it('reports a mismatch when existing has extra keys (ThoughtLink drift case)', function () {
|
|
47
|
+
// Regression guard for the bug that prompted this change: source was
|
|
48
|
+
// simplified to drop TextType drift keys (fontSize, bold, italic, etc.),
|
|
49
|
+
// but the old "extras tolerated" behavior left the stale keys on the DB
|
|
50
|
+
// row, causing type-switch demotion to persist.
|
|
51
|
+
var loader = internals();
|
|
52
|
+
var source = {
|
|
53
|
+
thoughtType: { object: { content: '', type: 'body1', linkedThoughtId: '' } },
|
|
54
|
+
};
|
|
55
|
+
var existing = {
|
|
56
|
+
thoughtType: {
|
|
57
|
+
object: {
|
|
58
|
+
content: '',
|
|
59
|
+
type: 'body1',
|
|
60
|
+
linkedThoughtId: '',
|
|
61
|
+
fontSize: 14,
|
|
62
|
+
bold: false,
|
|
63
|
+
italic: false,
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
expect(loader.findMismatchPath(source, existing, 'newThoughtTemplate')).not.toBeNull();
|
|
68
|
+
});
|
|
69
|
+
it('reports a mismatch when existing is missing a key present in source', function () {
|
|
70
|
+
var loader = internals();
|
|
71
|
+
var source = { content: '', type: 'body1', linkedThoughtId: '' };
|
|
72
|
+
var existing = { content: '', type: 'body1' };
|
|
73
|
+
expect(loader.findMismatchPath(source, existing, 'newThoughtTemplate')).not.toBeNull();
|
|
74
|
+
});
|
|
75
|
+
it('reports a mismatch for a nested value difference', function () {
|
|
76
|
+
var loader = internals();
|
|
77
|
+
var source = { thoughtType: { object: { type: 'body1' } } };
|
|
78
|
+
var existing = { thoughtType: { object: { type: 'body2' } } };
|
|
79
|
+
expect(loader.findMismatchPath(source, existing, 'newThoughtTemplate')).not.toBeNull();
|
|
80
|
+
});
|
|
81
|
+
it('treats source-side undefined values as equivalent to missing in existing', function () {
|
|
82
|
+
// `JSON.stringify` drops undefined values, so the DB cannot store them
|
|
83
|
+
// in the first place. Source declaring an undefined field must not be
|
|
84
|
+
// treated as drift vs an existing row that lacks the field.
|
|
85
|
+
var loader = internals();
|
|
86
|
+
var source = { content: 'hi', optional: undefined };
|
|
87
|
+
var existing = { content: 'hi' };
|
|
88
|
+
expect(loader.findMismatchPath(source, existing, 'newThoughtTemplate')).toBeNull();
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
describe('array comparison', function () {
|
|
92
|
+
it('reports a mismatch on array length', function () {
|
|
93
|
+
var loader = internals();
|
|
94
|
+
expect(loader.findMismatchPath([1, 2], [1, 2, 3], 'tags')).not.toBeNull();
|
|
95
|
+
});
|
|
96
|
+
it('reports a mismatch on array element difference', function () {
|
|
97
|
+
var loader = internals();
|
|
98
|
+
expect(loader.findMismatchPath([1, 2], [1, 3], 'tags')).not.toBeNull();
|
|
99
|
+
});
|
|
100
|
+
it('returns null for equal arrays', function () {
|
|
101
|
+
var loader = internals();
|
|
102
|
+
expect(loader.findMismatchPath([1, 2, 3], [1, 2, 3], 'tags')).toBeNull();
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
describe('primitive comparison', function () {
|
|
106
|
+
it('returns null for equal primitives', function () {
|
|
107
|
+
var loader = internals();
|
|
108
|
+
expect(loader.findMismatchPath('x', 'x', 'name')).toBeNull();
|
|
109
|
+
expect(loader.findMismatchPath(5, 5, 'count')).toBeNull();
|
|
110
|
+
});
|
|
111
|
+
it('reports a mismatch for different primitives', function () {
|
|
112
|
+
var loader = internals();
|
|
113
|
+
expect(loader.findMismatchPath('x', 'y', 'name')).not.toBeNull();
|
|
114
|
+
});
|
|
115
|
+
it('reports a mismatch for type differences', function () {
|
|
116
|
+
var loader = internals();
|
|
117
|
+
expect(loader.findMismatchPath('1', 1, 'value')).not.toBeNull();
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
//# sourceMappingURL=SourceRecordLoader.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SourceRecordLoader.test.js","sourceRoot":"","sources":["../../test/SourceRecordLoader.test.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AAC,yCAAyC,EAAE;YAC5C,IAAM,MAAM,GAAG,SAAS,EAAE,CAAC;YAC3B,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,GAAG,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;QAClE,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -53,13 +53,13 @@ var cascadeDeleteTests = function (driver, transactionContextFactory, dropTable)
|
|
|
53
53
|
case 0: return [4 /*yield*/, testEnv.beforeAll()];
|
|
54
54
|
case 1: return [2 /*return*/, _a.sent()];
|
|
55
55
|
}
|
|
56
|
-
}); }); },
|
|
56
|
+
}); }); }, 30000);
|
|
57
57
|
afterAll(function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
58
58
|
switch (_a.label) {
|
|
59
59
|
case 0: return [4 /*yield*/, testEnv.afterAll()];
|
|
60
60
|
case 1: return [2 /*return*/, _a.sent()];
|
|
61
61
|
}
|
|
62
|
-
}); }); },
|
|
62
|
+
}); }); }, 30000);
|
|
63
63
|
/**
|
|
64
64
|
* -------------------- Cascade Delete (holder → referenced) --------------------
|
|
65
65
|
*/
|
|
@@ -49,13 +49,13 @@ var columnTypeTests = function (driver, transactionContextFactory, dropTable) {
|
|
|
49
49
|
case 0: return [4 /*yield*/, testEnv.beforeAll()];
|
|
50
50
|
case 1: return [2 /*return*/, _a.sent()];
|
|
51
51
|
}
|
|
52
|
-
}); }); },
|
|
52
|
+
}); }); }, 30000);
|
|
53
53
|
afterAll(function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
54
54
|
switch (_a.label) {
|
|
55
55
|
case 0: return [4 /*yield*/, testEnv.afterAll()];
|
|
56
56
|
case 1: return [2 /*return*/, _a.sent()];
|
|
57
57
|
}
|
|
58
|
-
}); }); },
|
|
58
|
+
}); }); }, 30000);
|
|
59
59
|
test('Insert record with all null values', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
60
60
|
var testRecord, testTable, insertedRecord, fetchedRecord;
|
|
61
61
|
return __generator(this, function (_a) {
|
|
@@ -50,13 +50,13 @@ var crudTests = function (driver, transactionContextFactory, dropTable) {
|
|
|
50
50
|
case 0: return [4 /*yield*/, testEnv.beforeAll()];
|
|
51
51
|
case 1: return [2 /*return*/, _a.sent()];
|
|
52
52
|
}
|
|
53
|
-
}); }); },
|
|
53
|
+
}); }); }, 30000);
|
|
54
54
|
afterAll(function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
55
55
|
switch (_a.label) {
|
|
56
56
|
case 0: return [4 /*yield*/, testEnv.afterAll()];
|
|
57
57
|
case 1: return [2 /*return*/, _a.sent()];
|
|
58
58
|
}
|
|
59
|
-
}); }); },
|
|
59
|
+
}); }); }, 30000);
|
|
60
60
|
test('Insert', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
61
61
|
var testEmployee, emplyeeTable, insertedEmployee, fetchedEmployee;
|
|
62
62
|
return __generator(this, function (_a) {
|
|
@@ -685,7 +685,7 @@ var crudTests = function (driver, transactionContextFactory, dropTable) {
|
|
|
685
685
|
return [2 /*return*/];
|
|
686
686
|
}
|
|
687
687
|
});
|
|
688
|
-
}); },
|
|
688
|
+
}); }, 30000);
|
|
689
689
|
test('Case sensitivity', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
690
690
|
var testEmployee, emplyeeTable, insertedEmployee, queryNameInsensitive, nameResultsIns, queryNameSensitive, nameResultsSens;
|
|
691
691
|
return __generator(this, function (_a) {
|
|
@@ -50,13 +50,13 @@ var dynamicReferenceColumnTests = function (driver, dropTable) {
|
|
|
50
50
|
case 0: return [4 /*yield*/, testEnv.beforeAll()];
|
|
51
51
|
case 1: return [2 /*return*/, _a.sent()];
|
|
52
52
|
}
|
|
53
|
-
}); }); },
|
|
53
|
+
}); }); }, 30000);
|
|
54
54
|
afterAll(function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
55
55
|
switch (_a.label) {
|
|
56
56
|
case 0: return [4 /*yield*/, testEnv.afterAll()];
|
|
57
57
|
case 1: return [2 /*return*/, _a.sent()];
|
|
58
58
|
}
|
|
59
|
-
}); }); },
|
|
59
|
+
}); }); }, 30000);
|
|
60
60
|
test('should handle references to different types', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
61
61
|
var engineer, designer, engineerAssignment, designerAssignment, fetchedEngineerAssignment, fetchedDesignerAssignment;
|
|
62
62
|
var _a, _b, _c, _d;
|
|
@@ -49,13 +49,13 @@ var tableManagerTests = function (driver, dropTable, getColumnType, excludedTest
|
|
|
49
49
|
case 0: return [4 /*yield*/, testEnv.beforeAll()];
|
|
50
50
|
case 1: return [2 /*return*/, _a.sent()];
|
|
51
51
|
}
|
|
52
|
-
}); }); },
|
|
52
|
+
}); }); }, 30000);
|
|
53
53
|
afterAll(function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
54
54
|
switch (_a.label) {
|
|
55
55
|
case 0: return [4 /*yield*/, testEnv.afterAll()];
|
|
56
56
|
case 1: return [2 /*return*/, _a.sent()];
|
|
57
57
|
}
|
|
58
|
-
}); }); },
|
|
58
|
+
}); }); }, 30000);
|
|
59
59
|
afterEach(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
60
60
|
return __generator(this, function (_a) {
|
|
61
61
|
switch (_a.label) {
|
|
@@ -50,13 +50,13 @@ var transactionTests = function (driver, transactionContextFactory, dropTable) {
|
|
|
50
50
|
case 0: return [4 /*yield*/, testEnv.beforeAll()];
|
|
51
51
|
case 1: return [2 /*return*/, _a.sent()];
|
|
52
52
|
}
|
|
53
|
-
}); }); },
|
|
53
|
+
}); }); }, 30000);
|
|
54
54
|
afterAll(function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
55
55
|
switch (_a.label) {
|
|
56
56
|
case 0: return [4 /*yield*/, testEnv.afterAll()];
|
|
57
57
|
case 1: return [2 /*return*/, _a.sent()];
|
|
58
58
|
}
|
|
59
|
-
}); }); },
|
|
59
|
+
}); }); }, 30000);
|
|
60
60
|
test('Transaction with successful operations', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
61
61
|
var testEmployee1, testEmployee2, emplyeeTable, results, updatedEmp1, updatedEmp2, qb;
|
|
62
62
|
return __generator(this, function (_a) {
|