@mikro-orm/sql 7.1.6-dev.1 → 7.1.6-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.
@@ -494,6 +494,11 @@ export class AbstractSqlDriver extends DatabaseDriver {
494
494
  if (prop.fieldNames.every(name => typeof root[`${relationAlias}__${name}`] === 'undefined')) {
495
495
  return;
496
496
  }
497
+ // inline embeddables are mapped via their flattened child props; mapping the embedded root prop
498
+ // here would leak a raw column value into the snapshot and produce a phantom changeset
499
+ if (prop.kind === ReferenceKind.EMBEDDED && !prop.object && !meta.embeddable) {
500
+ return;
501
+ }
497
502
  if (prop.polymorphic && prop.kind !== ReferenceKind.EMBEDDED) {
498
503
  const discriminatorAlias = `${relationAlias}__${prop.fieldNames[0]}`;
499
504
  const discriminatorValue = root[discriminatorAlias];
@@ -2027,6 +2032,10 @@ export class AbstractSqlDriver extends DatabaseDriver {
2027
2032
  }
2028
2033
  const alias = '__p';
2029
2034
  const qb = this.createQueryBuilder(entityName, undefined, undefined, undefined, undefined, alias);
2035
+ // Select a constant instead of the default `*` — otherwise non-lazy `@Formula` properties
2036
+ // (and their embedded subqueries, which may contain their own `where`/cross-table refs)
2037
+ // leak into the SQL and corrupt the predicate extracted below. Only `from ... where` matters here.
2038
+ qb.select(raw('1'));
2030
2039
  qb.where(where);
2031
2040
  const sql = qb.getFormattedQuery();
2032
2041
  // Relation traversal produces join clauses whose aliased identifiers can't be inlined
@@ -9,6 +9,7 @@ export declare class MySqlSchemaHelper extends SchemaHelper {
9
9
  static readonly DEFAULT_VALUES: {
10
10
  'now()': string[];
11
11
  'current_timestamp(?)': string[];
12
+ 'curdate()': string[];
12
13
  '0': string[];
13
14
  };
14
15
  private static readonly PARTIAL_INDEX_RE;
@@ -5,6 +5,7 @@ export class MySqlSchemaHelper extends SchemaHelper {
5
5
  static DEFAULT_VALUES = {
6
6
  'now()': ['now()', 'current_timestamp'],
7
7
  'current_timestamp(?)': ['current_timestamp(?)'],
8
+ 'curdate()': ['(current_date)', 'curdate()'],
8
9
  '0': ['0', 'false'],
9
10
  };
10
11
  // Greedy `(.+)` so nested CASE expressions inside the predicate don't trip the match on
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/sql",
3
- "version": "7.1.6-dev.1",
3
+ "version": "7.1.6-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",
@@ -53,7 +53,7 @@
53
53
  "@mikro-orm/core": "^7.1.5"
54
54
  },
55
55
  "peerDependencies": {
56
- "@mikro-orm/core": "7.1.6-dev.1"
56
+ "@mikro-orm/core": "7.1.6-dev.11"
57
57
  },
58
58
  "engines": {
59
59
  "node": ">= 22.17.0"
@@ -894,7 +894,8 @@ export class SchemaComparator {
894
894
  // e.g. quotes might be added (https://github.com/mikro-orm/mikro-orm/issues/3827)
895
895
  const simplify = (str) => {
896
896
  return (str
897
- ?.replace(/_\w+'(.*?)'/g, '$1')
897
+ // lookbehind: only strip a real charset introducer, never an underscore inside a literal like 'a_b'
898
+ ?.replace(/(?<![\w'])_\w+'(.*?)'/g, '$1')
898
899
  .replace(/!=/g, '<>')
899
900
  .replace(/in\s*\((.*?)\)/gi, '= any (array[$1])')
900
901
  // MySQL normalizes count(*) to count(0)
package/typings.d.ts CHANGED
@@ -402,5 +402,5 @@ type ClassEntityColumnName<K, V, TOptions extends MikroKyselyPluginOptions = {}>
402
402
  readonly owner: object;
403
403
  } ? never : TOptions['columnNamingStrategy'] extends 'property' ? K : NV extends Scalar | readonly any[] ? K extends string ? SnakeCase<K> : never : K extends string ? ClassEntityJoinColumnName<SnakeCase<K>, NV> : never : never;
404
404
  type ClassEntityJoinColumnName<TName extends string, V> = PrimaryProperty<V> extends string ? `${TName}_${SnakeCase<PrimaryProperty<V>>}` : never;
405
- type ClassEntityColumnValue<V> = NonNullable<V> extends Scalar | readonly any[] ? V : Primary<NonNullable<V>>;
405
+ type ClassEntityColumnValue<V> = NonNullable<V> extends Scalar | readonly any[] ? V : V extends NonNullable<V> ? Primary<NonNullable<V>> : Primary<NonNullable<V>> | null;
406
406
  export {};