@mikro-orm/sql 7.1.2-dev.10 → 7.1.2-dev.12

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.
@@ -11,6 +11,7 @@ export declare class SqlitePlatform extends AbstractSqlPlatform {
11
11
  usesDefaultKeyword(): boolean;
12
12
  usesReturningStatement(): boolean;
13
13
  usesEnumCheckConstraints(): boolean;
14
+ supportsComments(): boolean;
14
15
  getCurrentTimestampSQL(length: number): string;
15
16
  getDateTimeTypeDeclarationSQL(column: {
16
17
  length: number;
@@ -18,6 +18,10 @@ export class SqlitePlatform extends AbstractSqlPlatform {
18
18
  usesEnumCheckConstraints() {
19
19
  return true;
20
20
  }
21
+ // sqlite has no table/column comments, so they cannot round-trip through introspection
22
+ supportsComments() {
23
+ return false;
24
+ }
21
25
  getCurrentTimestampSQL(length) {
22
26
  return `(strftime('%s', 'now') * 1000)`;
23
27
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/sql",
3
- "version": "7.1.2-dev.10",
3
+ "version": "7.1.2-dev.12",
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",
@@ -53,7 +53,7 @@
53
53
  "@mikro-orm/core": "^7.1.1"
54
54
  },
55
55
  "peerDependencies": {
56
- "@mikro-orm/core": "7.1.2-dev.10"
56
+ "@mikro-orm/core": "7.1.2-dev.12"
57
57
  },
58
58
  "engines": {
59
59
  "node": ">= 22.17.0"
@@ -975,6 +975,7 @@ export class DatabaseTable {
975
975
  mappedType instanceof t.float ||
976
976
  mappedType instanceof t.double;
977
977
  const supportsUnsigned = this.#platform.supportsUnsigned();
978
+ const supportsComments = this.#platform.supportsComments();
978
979
  const columnsMapped = sortedColumnKeys.reduce((o, col) => {
979
980
  const c = columns[col];
980
981
  // omit `autoincrement` from options so `serial` (metadata) and `int4` (introspection) collapse the same
@@ -1003,7 +1004,7 @@ export class DatabaseTable {
1003
1004
  precision: fixedPrecision ? null : (c.precision ?? null),
1004
1005
  scale: fixedPrecision ? null : (c.scale ?? null),
1005
1006
  default: defaultValue,
1006
- comment: c.comment || null,
1007
+ comment: supportsComments ? c.comment || null : null,
1007
1008
  collation: c.collation ?? null,
1008
1009
  enumItems: c.enumItems ?? [],
1009
1010
  mappedType: Utils.keys(t).find(k => t[k] === c.mappedType.constructor),
@@ -1092,8 +1093,9 @@ export class DatabaseTable {
1092
1093
  triggers: sortedTriggers,
1093
1094
  foreignKeys: sortedForeignKeys,
1094
1095
  // emit `comment` even when unset so introspection (which always reads it) matches metadata;
1095
- // collapse mysql's `""` for unset comments to `null` so both sources agree
1096
- comment: this.comment || null,
1096
+ // collapse mysql's `""` for unset comments to `null` so both sources agree. drop entirely on
1097
+ // platforms that can't read comments back (sqlite), where keeping it would flip the snapshot
1098
+ comment: supportsComments ? this.comment || null : null,
1097
1099
  };
1098
1100
  }
1099
1101
  }
@@ -339,7 +339,7 @@ export class SchemaComparator {
339
339
  fromTable,
340
340
  toTable,
341
341
  };
342
- if (this.diffComment(fromTable.comment, toTable.comment)) {
342
+ if (this.#platform.supportsComments() && this.diffComment(fromTable.comment, toTable.comment)) {
343
343
  tableDifferences.changedComment = toTable.comment;
344
344
  this.log(`table comment changed for ${tableDifferences.name}`, {
345
345
  fromTableComment: fromTable.comment,
@@ -713,7 +713,7 @@ export class SchemaComparator {
713
713
  log(`'default' changed for column ${fromTable.name}.${fromColumn.name}`, { fromColumn, toColumn });
714
714
  changedProperties.add('default');
715
715
  }
716
- if (this.diffComment(fromColumn.comment, toColumn.comment)) {
716
+ if (this.#platform.supportsComments() && this.diffComment(fromColumn.comment, toColumn.comment)) {
717
717
  log(`'comment' changed for column ${fromTable.name}.${fromColumn.name}`, { fromColumn, toColumn });
718
718
  changedProperties.add('comment');
719
719
  }