@mikro-orm/sql 7.2.6-dev.2 → 7.2.6-dev.20

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.
@@ -130,6 +130,10 @@ export class AbstractSqlConnection extends Connection {
130
130
  }
131
131
  catch (rollbackError) {
132
132
  this.logger.warn('query', `Failed to roll back transaction: ${rollbackError.message}`);
133
+ // the inner writes are still part of the outer transaction, so it must not commit them
134
+ if (options.ctx) {
135
+ options.ctx.failedSavepointRollback ??= new Error(`Cannot commit the transaction, rolling back to savepoint "${trx.savepointName}" failed: ${rollbackError.message}`, { cause: rollbackError });
136
+ }
133
137
  }
134
138
  throw error;
135
139
  }
@@ -203,6 +207,9 @@ export class AbstractSqlConnection extends Connection {
203
207
  if (ctx.isRolledBack) {
204
208
  return;
205
209
  }
210
+ if ('failedSavepointRollback' in ctx) {
211
+ throw ctx.failedSavepointRollback;
212
+ }
206
213
  await eventBroadcaster?.dispatchEvent(EventType.beforeTransactionCommit, ctx);
207
214
  if ('savepointName' in ctx) {
208
215
  await ctx.releaseSavepoint(ctx.savepointName).execute();
@@ -825,11 +825,11 @@ export class AbstractSqlDriver extends DatabaseDriver {
825
825
  value = this.platform.cloneEmbeddable(value);
826
826
  for (let i = 0; i < value.length; i++) {
827
827
  const item = value[i];
828
- value[i] = this.mapDataToFieldNames(item, false, prop.embeddedProps, options.convertCustomTypes);
828
+ value[i] = this.mapDataToFieldNames(item, false, this.variantProps(prop, item), options.convertCustomTypes);
829
829
  }
830
830
  }
831
831
  else {
832
- value = this.mapDataToFieldNames(value, false, prop.embeddedProps, options.convertCustomTypes);
832
+ value = this.mapDataToFieldNames(value, false, this.variantProps(prop, value), options.convertCustomTypes);
833
833
  }
834
834
  }
835
835
  if (typeof value === 'undefined' && this.platform.usesDefaultKeyword()) {
@@ -1095,11 +1095,11 @@ export class AbstractSqlDriver extends DatabaseDriver {
1095
1095
  if (prop.array && value) {
1096
1096
  for (let i = 0; i < value.length; i++) {
1097
1097
  const item = value[i];
1098
- value[i] = this.mapDataToFieldNames(item, false, prop.embeddedProps, options.convertCustomTypes);
1098
+ value[i] = this.mapDataToFieldNames(item, false, this.variantProps(prop, item), options.convertCustomTypes);
1099
1099
  }
1100
1100
  }
1101
1101
  else {
1102
- value = this.mapDataToFieldNames(value, false, prop.embeddedProps, options.convertCustomTypes);
1102
+ value = this.mapDataToFieldNames(value, false, this.variantProps(prop, value), options.convertCustomTypes);
1103
1103
  }
1104
1104
  }
1105
1105
  params.push(value ?? null);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/sql",
3
- "version": "7.2.6-dev.2",
3
+ "version": "7.2.6-dev.20",
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",
@@ -47,13 +47,13 @@
47
47
  "copy": "node ../../scripts/copy.mjs"
48
48
  },
49
49
  "dependencies": {
50
- "kysely": "0.29.6"
50
+ "kysely": "0.29.7"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@mikro-orm/core": "^7.2.5"
54
54
  },
55
55
  "peerDependencies": {
56
- "@mikro-orm/core": "7.2.6-dev.2"
56
+ "@mikro-orm/core": "7.2.6-dev.20"
57
57
  },
58
58
  "engines": {
59
59
  "node": ">= 22.17.0"
@@ -866,16 +866,10 @@ export class SchemaComparator {
866
866
  if (cols1.length === 0 && cols2.length === 0) {
867
867
  return true;
868
868
  }
869
- // If only one has column options, they don't match
870
- if (cols1.length !== cols2.length) {
871
- return false;
872
- }
873
- // Compare each column's options
874
- // Note: We don't check c1.name !== c2.name because the indexes already have matching columnNames
875
- // and the columns array is derived from those same column names
876
- for (let i = 0; i < cols1.length; i++) {
877
- const c1 = cols1[i];
878
- const c2 = cols2[i];
869
+ // introspection may omit entries for columns with default options, so match them by name
870
+ for (const name of index1.columnNames) {
871
+ const c1 = cols1.find(c => c.name === name) ?? { name };
872
+ const c2 = cols2.find(c => c.name === name) ?? { name };
879
873
  const sort1 = c1.sort?.toUpperCase() ?? 'ASC';
880
874
  const sort2 = c2.sort?.toUpperCase() ?? 'ASC';
881
875
  if (sort1 !== sort2) {