@mikro-orm/core 7.0.9-dev.10 → 7.0.9-dev.11

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.
@@ -310,7 +310,7 @@ export class DatabaseDriver {
310
310
  if (prop.joinColumns && Array.isArray(data[k])) {
311
311
  const copy = Utils.flatten(data[k]);
312
312
  delete data[k];
313
- prop.joinColumns.forEach((joinColumn, idx) => (data[joinColumn] = copy[idx]));
313
+ (prop.ownColumns ?? prop.joinColumns).forEach(col => (data[col] = copy[prop.joinColumns.indexOf(col)]));
314
314
  return;
315
315
  }
316
316
  if (prop.joinColumns?.length > 1 && data[k] == null) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/core",
3
- "version": "7.0.9-dev.10",
3
+ "version": "7.0.9-dev.11",
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",
@@ -323,14 +323,47 @@ export class Platform {
323
323
  }
324
324
  /** Serializes a string array into its database storage format. */
325
325
  marshallArray(values) {
326
- return values.join(',');
326
+ return values.map(v => (/[,",\\]/.test(v) ? JSON.stringify(v) : v)).join(',');
327
327
  }
328
328
  /** Deserializes a database-stored array string back into a string array. */
329
329
  unmarshallArray(value) {
330
330
  if (value === '') {
331
331
  return [];
332
332
  }
333
- return value.split(',');
333
+ if (!value.includes('"')) {
334
+ return value.split(',');
335
+ }
336
+ const result = [];
337
+ let i = 0;
338
+ while (i < value.length) {
339
+ if (value[i] === '"') {
340
+ let j = i + 1;
341
+ while (j < value.length) {
342
+ if (value[j] === '\\') {
343
+ j += 2;
344
+ }
345
+ else if (value[j] === '"') {
346
+ j++;
347
+ break;
348
+ }
349
+ else {
350
+ j++;
351
+ }
352
+ }
353
+ result.push(JSON.parse(value.substring(i, j)));
354
+ i = j + 1;
355
+ }
356
+ else {
357
+ const comma = value.indexOf(',', i);
358
+ if (comma === -1) {
359
+ result.push(value.substring(i));
360
+ break;
361
+ }
362
+ result.push(value.substring(i, comma));
363
+ i = comma + 1;
364
+ }
365
+ }
366
+ return result;
334
367
  }
335
368
  getBlobDeclarationSQL() {
336
369
  return 'blob';
package/utils/Utils.js CHANGED
@@ -132,7 +132,7 @@ export function parseJsonSafe(value) {
132
132
  /** Collection of general-purpose utility methods used throughout the ORM. */
133
133
  export class Utils {
134
134
  static PK_SEPARATOR = '~~~';
135
- static #ORM_VERSION = '7.0.9-dev.10';
135
+ static #ORM_VERSION = '7.0.9-dev.11';
136
136
  /**
137
137
  * Checks if the argument is instance of `Object`. Returns false for arrays.
138
138
  */