@mikro-orm/core 6.2.10-dev.6 → 6.2.10-dev.60

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 (64) hide show
  1. package/EntityManager.d.ts +1 -2
  2. package/EntityManager.js +24 -22
  3. package/decorators/Check.js +1 -2
  4. package/decorators/CreateRequestContext.js +2 -3
  5. package/decorators/Embeddable.js +1 -2
  6. package/decorators/Embedded.js +1 -2
  7. package/decorators/Entity.js +1 -2
  8. package/decorators/Enum.js +1 -2
  9. package/decorators/Filter.js +1 -2
  10. package/decorators/Formula.js +1 -2
  11. package/decorators/Indexed.d.ts +3 -3
  12. package/decorators/Indexed.js +2 -3
  13. package/decorators/ManyToMany.js +1 -2
  14. package/decorators/ManyToOne.js +1 -2
  15. package/decorators/OneToMany.js +2 -3
  16. package/decorators/OneToOne.d.ts +1 -1
  17. package/decorators/OneToOne.js +1 -2
  18. package/decorators/PrimaryKey.d.ts +3 -2
  19. package/decorators/PrimaryKey.js +2 -3
  20. package/decorators/Property.js +1 -2
  21. package/decorators/hooks.js +10 -11
  22. package/drivers/DatabaseDriver.js +1 -1
  23. package/drivers/IDatabaseDriver.d.ts +2 -1
  24. package/entity/ArrayCollection.d.ts +0 -1
  25. package/entity/EntityIdentifier.d.ts +1 -1
  26. package/entity/EntityLoader.js +3 -0
  27. package/entity/Reference.d.ts +0 -1
  28. package/entity/Reference.js +10 -7
  29. package/entity/WrappedEntity.d.ts +0 -1
  30. package/entity/wrap.js +2 -3
  31. package/events/TransactionEventBroadcaster.d.ts +2 -2
  32. package/metadata/MetadataDiscovery.js +4 -3
  33. package/naming-strategy/AbstractNamingStrategy.d.ts +8 -0
  34. package/naming-strategy/AbstractNamingStrategy.js +12 -0
  35. package/naming-strategy/NamingStrategy.d.ts +21 -0
  36. package/package.json +2 -2
  37. package/platforms/Platform.d.ts +0 -1
  38. package/platforms/Platform.js +0 -3
  39. package/serialization/EntitySerializer.js +2 -2
  40. package/types/BigIntType.d.ts +2 -2
  41. package/types/BlobType.d.ts +0 -1
  42. package/types/DecimalType.d.ts +2 -2
  43. package/types/Type.d.ts +1 -2
  44. package/types/Uint8ArrayType.d.ts +0 -1
  45. package/typings.d.ts +14 -14
  46. package/unit-of-work/ChangeSet.d.ts +0 -1
  47. package/unit-of-work/ChangeSetPersister.d.ts +1 -1
  48. package/unit-of-work/ChangeSetPersister.js +2 -2
  49. package/unit-of-work/UnitOfWork.d.ts +1 -1
  50. package/unit-of-work/UnitOfWork.js +32 -18
  51. package/utils/Configuration.js +2 -2
  52. package/utils/ConfigurationLoader.js +1 -0
  53. package/utils/Cursor.d.ts +0 -1
  54. package/utils/DataloaderUtils.d.ts +3 -3
  55. package/utils/DataloaderUtils.js +4 -4
  56. package/utils/EntityComparator.d.ts +13 -0
  57. package/utils/EntityComparator.js +62 -34
  58. package/utils/RawQueryFragment.d.ts +1 -2
  59. package/utils/RawQueryFragment.js +4 -4
  60. package/utils/Utils.d.ts +4 -6
  61. package/utils/Utils.js +13 -10
  62. package/utils/clone.js +1 -2
  63. package/utils/upsert-utils.d.ts +3 -2
  64. package/utils/upsert-utils.js +4 -5
@@ -206,6 +206,50 @@ class EntityComparator {
206
206
  this.snapshotGenerators.set(entityName, snapshotGenerator);
207
207
  return snapshotGenerator;
208
208
  }
209
+ /**
210
+ * @internal
211
+ */
212
+ propName(name, parent = 'result') {
213
+ return parent + this.wrap(name);
214
+ }
215
+ /**
216
+ * @internal respects nested composite keys, e.g. `[1, [2, 3]]`
217
+ */
218
+ createCompositeKeyArray(prop, parents = []) {
219
+ if (!prop.targetMeta) {
220
+ let fieldName = prop.fieldNames[0];
221
+ // traverse all parents, mapping my field name to each parent's field name until we reach the root
222
+ for (let i = parents.length - 1; i >= 0; i--) {
223
+ const parent = parents[i];
224
+ // look for the field name in the parent's referencedColumnNames, except for M:N without a custom pivot entity
225
+ // (in that case, the field names are the referenced PK's )
226
+ const target = parent.kind === enums_1.ReferenceKind.MANY_TO_MANY && parent.pivotEntity === parent.pivotTable ?
227
+ parent.referencedPKs : parent.referencedColumnNames;
228
+ const idx = target.indexOf(fieldName);
229
+ fieldName = parent.fieldNames[idx];
230
+ }
231
+ return this.propName(fieldName);
232
+ }
233
+ const parts = [];
234
+ prop.targetMeta.getPrimaryProps().forEach(pk => {
235
+ const part = this.createCompositeKeyArray(pk, [...parents, prop]);
236
+ parts.push(part);
237
+ });
238
+ return this.formatCompositeKeyPart(parts);
239
+ }
240
+ /**
241
+ * @internal
242
+ */
243
+ formatCompositeKeyPart(part) {
244
+ if (!Array.isArray(part)) {
245
+ return part;
246
+ }
247
+ if (part.length === 1) {
248
+ return this.formatCompositeKeyPart(part[0]);
249
+ }
250
+ const formatted = part.map(this.formatCompositeKeyPart).join(', ');
251
+ return `[${formatted}]`;
252
+ }
209
253
  /**
210
254
  * @internal Highly performance-sensitive method.
211
255
  */
@@ -217,22 +261,6 @@ class EntityComparator {
217
261
  const meta = this.metadata.get(entityName);
218
262
  const lines = [];
219
263
  const context = new Map();
220
- const propName = (name, parent = 'result') => parent + this.wrap(name);
221
- // respects nested composite keys, e.g. `[1, [2, 3]]`
222
- const createCompositeKeyArray = (prop, fieldNames = prop.fieldNames, idx = 0) => {
223
- if (!prop.targetMeta) {
224
- return propName(fieldNames[idx++]);
225
- }
226
- const parts = [];
227
- for (const pk of prop.targetMeta.getPrimaryProps()) {
228
- parts.push(createCompositeKeyArray(pk, fieldNames, idx));
229
- idx += pk.fieldNames.length;
230
- }
231
- if (parts.length < 2) {
232
- return parts[0];
233
- }
234
- return '[' + parts.join(', ') + ']';
235
- };
236
264
  const tz = this.platform.getTimezone();
237
265
  const parseDate = (key, value, padding = '') => {
238
266
  lines.push(`${padding} if (${value} == null || ${value} instanceof Date) {`);
@@ -255,28 +283,28 @@ class EntityComparator {
255
283
  return;
256
284
  }
257
285
  if (prop.targetMeta && prop.fieldNames.length > 1) {
258
- lines.push(` if (${prop.fieldNames.map(field => `typeof ${propName(field)} === 'undefined'`).join(' && ')}) {`);
259
- lines.push(` } else if (${prop.fieldNames.map(field => `${propName(field)} != null`).join(' && ')}) {`);
260
- lines.push(` ret${this.wrap(prop.name)} = ${createCompositeKeyArray(prop)};`);
261
- lines.push(...prop.fieldNames.map(field => ` ${propName(field, 'mapped')} = true;`));
262
- lines.push(` } else if (${prop.fieldNames.map(field => `${propName(field)} == null`).join(' && ')}) {\n ret${this.wrap(prop.name)} = null;`);
263
- lines.push(...prop.fieldNames.map(field => ` ${propName(field, 'mapped')} = true;`), ' }');
286
+ lines.push(` if (${prop.fieldNames.map(field => `typeof ${this.propName(field)} === 'undefined'`).join(' && ')}) {`);
287
+ lines.push(` } else if (${prop.fieldNames.map(field => `${this.propName(field)} != null`).join(' && ')}) {`);
288
+ lines.push(` ret${this.wrap(prop.name)} = ${this.createCompositeKeyArray(prop)};`);
289
+ lines.push(...prop.fieldNames.map(field => ` ${this.propName(field, 'mapped')} = true;`));
290
+ lines.push(` } else if (${prop.fieldNames.map(field => `${this.propName(field)} == null`).join(' && ')}) {\n ret${this.wrap(prop.name)} = null;`);
291
+ lines.push(...prop.fieldNames.map(field => ` ${this.propName(field, 'mapped')} = true;`), ' }');
264
292
  return;
265
293
  }
266
294
  if (prop.embedded && (meta.embeddable || meta.properties[prop.embedded[0]].object)) {
267
295
  return;
268
296
  }
269
297
  if (prop.runtimeType === 'boolean') {
270
- lines.push(` if (typeof ${propName(prop.fieldNames[0])} !== 'undefined') {`);
271
- lines.push(` ret${this.wrap(prop.name)} = ${propName(prop.fieldNames[0])} == null ? ${propName(prop.fieldNames[0])} : !!${propName(prop.fieldNames[0])};`);
272
- lines.push(` ${propName(prop.fieldNames[0], 'mapped')} = true;`);
298
+ lines.push(` if (typeof ${this.propName(prop.fieldNames[0])} !== 'undefined') {`);
299
+ lines.push(` ret${this.wrap(prop.name)} = ${this.propName(prop.fieldNames[0])} == null ? ${this.propName(prop.fieldNames[0])} : !!${this.propName(prop.fieldNames[0])};`);
300
+ lines.push(` ${this.propName(prop.fieldNames[0], 'mapped')} = true;`);
273
301
  lines.push(` }`);
274
302
  }
275
303
  else if (prop.runtimeType === 'Date') {
276
- lines.push(` if (typeof ${propName(prop.fieldNames[0])} !== 'undefined') {`);
304
+ lines.push(` if (typeof ${this.propName(prop.fieldNames[0])} !== 'undefined') {`);
277
305
  context.set('parseDate', (value) => this.platform.parseDate(value));
278
- parseDate('ret' + this.wrap(prop.name), propName(prop.fieldNames[0]));
279
- lines.push(` ${propName(prop.fieldNames[0], 'mapped')} = true;`);
306
+ parseDate('ret' + this.wrap(prop.name), this.propName(prop.fieldNames[0]));
307
+ lines.push(` ${this.propName(prop.fieldNames[0], 'mapped')} = true;`);
280
308
  lines.push(` }`);
281
309
  }
282
310
  else if (prop.kind === enums_1.ReferenceKind.EMBEDDED && (prop.object || meta.embeddable)) {
@@ -288,15 +316,15 @@ class EntityComparator {
288
316
  }
289
317
  return item == null ? item : this.getResultMapper(prop.type)(item);
290
318
  });
291
- lines.push(` if (typeof ${propName(prop.fieldNames[0])} !== 'undefined') {`);
292
- lines.push(` ret${this.wrap(prop.name)} = ${propName(prop.fieldNames[0])} == null ? ${propName(prop.fieldNames[0])} : mapEmbeddedResult_${idx}(${propName(prop.fieldNames[0])});`);
293
- lines.push(` ${propName(prop.fieldNames[0], 'mapped')} = true;`);
319
+ lines.push(` if (typeof ${this.propName(prop.fieldNames[0])} !== 'undefined') {`);
320
+ lines.push(` ret${this.wrap(prop.name)} = ${this.propName(prop.fieldNames[0])} == null ? ${this.propName(prop.fieldNames[0])} : mapEmbeddedResult_${idx}(${this.propName(prop.fieldNames[0])});`);
321
+ lines.push(` ${this.propName(prop.fieldNames[0], 'mapped')} = true;`);
294
322
  lines.push(` }`);
295
323
  }
296
324
  else if (prop.kind !== enums_1.ReferenceKind.EMBEDDED) {
297
- lines.push(` if (typeof ${propName(prop.fieldNames[0])} !== 'undefined') {`);
298
- lines.push(` ret${this.wrap(prop.name)} = ${propName(prop.fieldNames[0])};`);
299
- lines.push(` ${propName(prop.fieldNames[0], 'mapped')} = true;`);
325
+ lines.push(` if (typeof ${this.propName(prop.fieldNames[0])} !== 'undefined') {`);
326
+ lines.push(` ret${this.wrap(prop.name)} = ${this.propName(prop.fieldNames[0])};`);
327
+ lines.push(` ${this.propName(prop.fieldNames[0], 'mapped')} = true;`);
300
328
  lines.push(` }`);
301
329
  }
302
330
  });
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { inspect } from 'util';
3
2
  import type { AnyString, Dictionary, EntityKey } from '../typings';
4
3
  export declare class RawQueryFragment {
@@ -89,7 +88,7 @@ export declare function raw<T extends object = any, R = any>(sql: EntityKey<T> |
89
88
  export declare function sql(sql: readonly string[], ...values: unknown[]): any;
90
89
  export declare namespace sql {
91
90
  var ref: <T extends object>(...keys: string[]) => RawQueryFragment;
92
- var now: (length?: number | undefined) => string;
91
+ var now: (length?: number) => string;
93
92
  var lower: <T extends object>(key: string | ((alias: string) => string)) => string;
94
93
  var upper: <T extends object>(key: string | ((alias: string) => string)) => string;
95
94
  }
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createSqlFunction = exports.sql = exports.raw = exports.ALIAS_REPLACEMENT_RE = exports.ALIAS_REPLACEMENT = exports.RawQueryFragment = void 0;
3
+ exports.ALIAS_REPLACEMENT_RE = exports.ALIAS_REPLACEMENT = exports.RawQueryFragment = void 0;
4
+ exports.raw = raw;
5
+ exports.sql = sql;
6
+ exports.createSqlFunction = createSqlFunction;
4
7
  const util_1 = require("util");
5
8
  const Utils_1 = require("./Utils");
6
9
  class RawQueryFragment {
@@ -152,7 +155,6 @@ function raw(sql, params) {
152
155
  }
153
156
  return new RawQueryFragment(sql, params);
154
157
  }
155
- exports.raw = raw;
156
158
  /**
157
159
  * Alternative to the `raw()` helper allowing to use it as a tagged template function for the simple cases.
158
160
  *
@@ -174,14 +176,12 @@ function sql(sql, ...values) {
174
176
  return valueExists ? text + '?' : text;
175
177
  }, ''), values);
176
178
  }
177
- exports.sql = sql;
178
179
  function createSqlFunction(func, key) {
179
180
  if (typeof key === 'string') {
180
181
  return raw(`${func}(${key})`);
181
182
  }
182
183
  return raw(a => `${func}(${(key(a))})`);
183
184
  }
184
- exports.createSqlFunction = createSqlFunction;
185
185
  sql.ref = (...keys) => raw('??', [keys.join('.')]);
186
186
  sql.now = (length) => raw('current_timestamp' + (length == null ? '' : `(${length})`));
187
187
  sql.lower = (key) => createSqlFunction('lower', key);
package/utils/Utils.d.ts CHANGED
@@ -1,5 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  import { type GlobbyOptions } from 'globby';
4
2
  import { type URL } from 'url';
5
3
  import type { Dictionary, EntityData, EntityDictionary, EntityKey, EntityMetadata, EntityName, EntityProperty, IMetadataStorage, Primary } from '../typings';
@@ -190,9 +188,9 @@ export declare class Utils {
190
188
  static isCollection<T extends object, O extends object = object>(item: any): item is Collection<T, O>;
191
189
  static fileURLToPath(url: string | URL): string;
192
190
  /**
193
- * Resolves and normalizes a series of path parts relative to each preceeding part.
191
+ * Resolves and normalizes a series of path parts relative to each preceding part.
194
192
  * If any part is a `file:` URL, it is converted to a local path. If any part is an
195
- * absolute path, it replaces preceeding paths (similar to `path.resolve` in NodeJS).
193
+ * absolute path, it replaces preceding paths (similar to `path.resolve` in NodeJS).
196
194
  * Trailing directory separators are removed, and all directory separators are converted
197
195
  * to POSIX-style separators (`/`).
198
196
  */
@@ -257,10 +255,10 @@ export declare class Utils {
257
255
  static keys<T extends object>(obj: T): (keyof T)[];
258
256
  static values<T extends object>(obj: T): T[keyof T][];
259
257
  static entries<T extends object>(obj: T): [keyof T, T[keyof T]][];
260
- static isRawSql(value: unknown): value is {
258
+ static isRawSql<T = {
261
259
  sql: string;
262
260
  params: unknown[];
263
261
  use: () => void;
264
- };
262
+ }>(value: unknown): value is T;
265
263
  static primaryKeyToObject<T>(meta: EntityMetadata<T>, primaryKey: Primary<T> | T, visible?: (keyof T)[]): T;
266
264
  }
package/utils/Utils.js CHANGED
@@ -3,7 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Utils = exports.parseJsonSafe = exports.equals = exports.compareBuffers = exports.compareBooleans = exports.compareArrays = exports.compareObjects = exports.ObjectBindingPattern = void 0;
6
+ exports.Utils = exports.ObjectBindingPattern = void 0;
7
+ exports.compareObjects = compareObjects;
8
+ exports.compareArrays = compareArrays;
9
+ exports.compareBooleans = compareBooleans;
10
+ exports.compareBuffers = compareBuffers;
11
+ exports.equals = equals;
12
+ exports.parseJsonSafe = parseJsonSafe;
7
13
  const module_1 = require("module");
8
14
  const globby_1 = __importDefault(require("globby"));
9
15
  const path_1 = require("path");
@@ -67,7 +73,6 @@ function compareObjects(a, b) {
67
73
  }
68
74
  return true;
69
75
  }
70
- exports.compareObjects = compareObjects;
71
76
  function compareArrays(a, b) {
72
77
  const length = a.length;
73
78
  if (length !== b.length) {
@@ -81,13 +86,11 @@ function compareArrays(a, b) {
81
86
  }
82
87
  return true;
83
88
  }
84
- exports.compareArrays = compareArrays;
85
89
  function compareBooleans(a, b) {
86
90
  a = typeof a === 'number' ? Boolean(a) : a;
87
91
  b = typeof b === 'number' ? Boolean(b) : b;
88
92
  return a === b;
89
93
  }
90
- exports.compareBooleans = compareBooleans;
91
94
  function compareBuffers(a, b) {
92
95
  const length = a.length;
93
96
  if (length !== b.length) {
@@ -100,7 +103,6 @@ function compareBuffers(a, b) {
100
103
  }
101
104
  return true;
102
105
  }
103
- exports.compareBuffers = compareBuffers;
104
106
  /**
105
107
  * Checks if arguments are deeply (but not strictly) equal.
106
108
  */
@@ -119,7 +121,6 @@ function equals(a, b) {
119
121
  }
120
122
  return Number.isNaN(a) && Number.isNaN(b);
121
123
  }
122
- exports.equals = equals;
123
124
  const equalsFn = equals;
124
125
  function parseJsonSafe(value) {
125
126
  if (typeof value === 'string') {
@@ -133,7 +134,6 @@ function parseJsonSafe(value) {
133
134
  }
134
135
  return value;
135
136
  }
136
- exports.parseJsonSafe = parseJsonSafe;
137
137
  class Utils {
138
138
  static PK_SEPARATOR = '~~~';
139
139
  /* istanbul ignore next */
@@ -386,20 +386,23 @@ class Utils {
386
386
  const ret = [];
387
387
  const tokens = this.tokenize(func);
388
388
  let inside = 0;
389
+ let currentBlockStart = 0;
389
390
  for (let i = 0; i < tokens.length; i++) {
390
391
  const token = tokens[i];
391
392
  if (token.type === 'Identifier' && token.value === methodName) {
392
393
  inside = 1;
394
+ currentBlockStart = i;
393
395
  continue;
394
396
  }
395
397
  if (inside === 1 && token.type === 'Punctuator' && token.value === '(') {
396
398
  inside = 2;
399
+ currentBlockStart = i;
397
400
  continue;
398
401
  }
399
402
  if (inside === 2 && token.type === 'Punctuator' && token.value === ')') {
400
403
  break;
401
404
  }
402
- if (inside === 2 && token.type === 'Punctuator' && token.value === '{') {
405
+ if (inside === 2 && token.type === 'Punctuator' && token.value === '{' && i === currentBlockStart + 1) {
403
406
  ret.push(exports.ObjectBindingPattern);
404
407
  i = tokens.findIndex((t, idx) => idx > i + 2 && t.type === 'Punctuator' && t.value === '}');
405
408
  continue;
@@ -704,9 +707,9 @@ class Utils {
704
707
  return (0, url_1.fileURLToPath)(url);
705
708
  }
706
709
  /**
707
- * Resolves and normalizes a series of path parts relative to each preceeding part.
710
+ * Resolves and normalizes a series of path parts relative to each preceding part.
708
711
  * If any part is a `file:` URL, it is converted to a local path. If any part is an
709
- * absolute path, it replaces preceeding paths (similar to `path.resolve` in NodeJS).
712
+ * absolute path, it replaces preceding paths (similar to `path.resolve` in NodeJS).
710
713
  * Trailing directory separators are removed, and all directory separators are converted
711
714
  * to POSIX-style separators (`/`).
712
715
  */
package/utils/clone.js CHANGED
@@ -5,7 +5,7 @@
5
5
  * @internal
6
6
  */
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.clone = void 0;
8
+ exports.clone = clone;
9
9
  const events_1 = require("events");
10
10
  const RawQueryFragment_1 = require("./RawQueryFragment");
11
11
  function clone(parent, respectCustomCloneMethod = true) {
@@ -124,4 +124,3 @@ function clone(parent, respectCustomCloneMethod = true) {
124
124
  }
125
125
  return _clone(parent);
126
126
  }
127
- exports.clone = clone;
@@ -1,6 +1,7 @@
1
1
  import type { EntityData, EntityMetadata } from '../typings';
2
2
  import type { UpsertOptions } from '../drivers/IDatabaseDriver';
3
+ import type { RawQueryFragment } from '../utils/RawQueryFragment';
3
4
  /** @internal */
4
- export declare function getOnConflictFields<T>(meta: EntityMetadata<T> | undefined, data: EntityData<T>, uniqueFields: (keyof T)[], options: UpsertOptions<T>): (keyof T)[];
5
+ export declare function getOnConflictFields<T>(meta: EntityMetadata<T> | undefined, data: EntityData<T>, uniqueFields: (keyof T)[] | RawQueryFragment, options: UpsertOptions<T>): (keyof T)[];
5
6
  /** @internal */
6
- export declare function getOnConflictReturningFields<T>(meta: EntityMetadata<T> | undefined, data: EntityData<T>, uniqueFields: (keyof T)[], options: UpsertOptions<T>): (keyof T)[] | '*';
7
+ export declare function getOnConflictReturningFields<T>(meta: EntityMetadata<T> | undefined, data: EntityData<T>, uniqueFields: (keyof T)[] | RawQueryFragment, options: UpsertOptions<T>): (keyof T)[] | '*';
@@ -1,26 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getOnConflictReturningFields = exports.getOnConflictFields = void 0;
3
+ exports.getOnConflictFields = getOnConflictFields;
4
+ exports.getOnConflictReturningFields = getOnConflictReturningFields;
4
5
  /** @internal */
5
6
  function getOnConflictFields(meta, data, uniqueFields, options) {
6
7
  if (options.onConflictMergeFields) {
7
8
  return options.onConflictMergeFields;
8
9
  }
9
10
  const keys = Object.keys(data).filter(f => {
10
- return !uniqueFields.includes(f) && !meta?.properties[f]?.embeddable;
11
+ return Array.isArray(uniqueFields) && !uniqueFields.includes(f) && !meta?.properties[f]?.embeddable;
11
12
  });
12
13
  if (options.onConflictExcludeFields) {
13
14
  return keys.filter(f => !options.onConflictExcludeFields.includes(f));
14
15
  }
15
16
  return keys;
16
17
  }
17
- exports.getOnConflictFields = getOnConflictFields;
18
18
  /** @internal */
19
19
  function getOnConflictReturningFields(meta, data, uniqueFields, options) {
20
20
  if (!meta) {
21
21
  return '*';
22
22
  }
23
- const keys = meta.comparableProps.filter(p => !p.lazy && !p.embeddable && !uniqueFields.includes(p.name)).map(p => p.name);
23
+ const keys = meta.comparableProps.filter(p => !p.lazy && !p.embeddable && Array.isArray(uniqueFields) && !uniqueFields.includes(p.name)).map(p => p.name);
24
24
  if (meta.versionProperty) {
25
25
  keys.push(meta.versionProperty);
26
26
  }
@@ -35,4 +35,3 @@ function getOnConflictReturningFields(meta, data, uniqueFields, options) {
35
35
  }
36
36
  return keys.filter(key => !(key in data));
37
37
  }
38
- exports.getOnConflictReturningFields = getOnConflictReturningFields;