@mikro-orm/core 7.2.10-dev.8 → 7.2.10-dev.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/core",
3
- "version": "7.2.10-dev.8",
3
+ "version": "7.2.10-dev.9",
4
4
  "description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.",
5
5
  "keywords": [
6
6
  "data-mapper",
@@ -366,7 +366,7 @@ export class Platform {
366
366
  }
367
367
  /** Serializes a string array into its database storage format. */
368
368
  marshallArray(values) {
369
- return values.map(v => (/[,",\\]/.test(v) ? JSON.stringify(v) : v)).join(',');
369
+ return values.map(v => (/[,",\\]/.test(v) || (v === '' && values.length === 1) ? JSON.stringify(v) : v)).join(',');
370
370
  }
371
371
  /** Deserializes a database-stored array string back into a string array. */
372
372
  unmarshallArray(value) {
@@ -406,6 +406,9 @@ export class Platform {
406
406
  i = comma + 1;
407
407
  }
408
408
  }
409
+ if (value.endsWith(',')) {
410
+ result.push('');
411
+ }
409
412
  return result;
410
413
  }
411
414
  getBlobDeclarationSQL() {
package/typings.d.ts CHANGED
@@ -1190,6 +1190,7 @@ export interface EntityMetadata<Entity = any, Class extends EntityCtor<Entity> =
1190
1190
  comparableProps: EntityProperty<Entity>[];
1191
1191
  trackingProps: EntityProperty<Entity>[];
1192
1192
  hydrateProps: EntityProperty<Entity>[];
1193
+ updateHookProps: EntityProperty<Entity>[];
1193
1194
  validateProps: EntityProperty<Entity>[];
1194
1195
  uniqueProps: EntityProperty<Entity>[];
1195
1196
  getterProps: EntityProperty<Entity>[];
package/typings.js CHANGED
@@ -216,6 +216,7 @@ export class EntityMetadata {
216
216
  const onlyGetter = prop.getter && !prop.setter && prop.persist === false;
217
217
  return !prop.inherited && prop.hydrate !== false && !discriminator && !prop.embedded && !onlyGetter;
218
218
  });
219
+ this.updateHookProps = this.hydrateProps.filter(prop => prop.onUpdate || prop.kind === ReferenceKind.EMBEDDED);
219
220
  this.trackingProps = this.hydrateProps.filter(prop => {
220
221
  return (!prop.getter &&
221
222
  !prop.setter &&
@@ -67,7 +67,7 @@ export class ChangeSetComputer {
67
67
  // Execute `onCreate` and `onUpdate` on properties recursively, saves `onUpdate` results
68
68
  // to the `map` as we want to apply those only if something else changed.
69
69
  if (type === ChangeSetType.UPDATE) {
70
- for (const prop of meta.hydrateProps) {
70
+ for (const prop of meta.updateHookProps) {
71
71
  this.processPropertyInitializers(entity, prop, type, map);
72
72
  }
73
73
  }
@@ -107,8 +107,9 @@ export class ChangeSetComputer {
107
107
  }
108
108
  if (prop.kind === ReferenceKind.EMBEDDED && entity[prop.name]) {
109
109
  const items = prop.array ? entity[prop.name] : [entity[prop.name]];
110
+ const embeddedProps = type === ChangeSetType.UPDATE ? prop.targetMeta.updateHookProps : prop.targetMeta.hydrateProps;
110
111
  for (const item of items) {
111
- for (const embeddedProp of prop.targetMeta.hydrateProps) {
112
+ for (const embeddedProp of embeddedProps) {
112
113
  this.processPropertyInitializers(item, embeddedProp, type, map, nested || prop.object);
113
114
  }
114
115
  }
package/utils/Utils.js CHANGED
@@ -153,7 +153,7 @@ export function parseJsonSafe(value) {
153
153
  /** Collection of general-purpose utility methods used throughout the ORM. */
154
154
  export class Utils {
155
155
  static PK_SEPARATOR = '~~~';
156
- static #ORM_VERSION = '7.2.10-dev.8';
156
+ static #ORM_VERSION = '7.2.10-dev.9';
157
157
  /** Default session variable name backing an RLS filter argument (`current_setting('mikro.<filter>.<arg>')`). */
158
158
  static getRlsSettingName(filterName, argName) {
159
159
  return `mikro.${filterName}.${argName}`;