@mikro-orm/sql 7.2.7-dev.10 → 7.2.7-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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/sql",
3
- "version": "7.2.7-dev.10",
3
+ "version": "7.2.7-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.2.6"
54
54
  },
55
55
  "peerDependencies": {
56
- "@mikro-orm/core": "7.2.7-dev.10"
56
+ "@mikro-orm/core": "7.2.7-dev.12"
57
57
  },
58
58
  "engines": {
59
59
  "node": ">= 22.17.0"
@@ -1,4 +1,4 @@
1
- import { isRaw, LockMode, raw, Utils, } from '@mikro-orm/core';
1
+ import { isRaw, LockMode, raw, SUBQUERY_BRAND, Utils, } from '@mikro-orm/core';
2
2
  import { QueryType } from './enums.js';
3
3
  /** @internal */
4
4
  export class NativeQueryBuilder {
@@ -529,3 +529,9 @@ export class NativeQueryBuilder {
529
529
  return this.platform.quoteIdentifier(id);
530
530
  }
531
531
  }
532
+ // prototype-level brand recognized by `isSubquery()`, JSON payloads cannot forge it
533
+ Object.defineProperty(NativeQueryBuilder.prototype, SUBQUERY_BRAND, {
534
+ value: true,
535
+ writable: false,
536
+ configurable: false,
537
+ });
@@ -1,5 +1,5 @@
1
1
  var _a;
2
- import { EntityMetadata, helper, inspect, isRaw, LoadStrategy, LockMode, PopulateHint, QueryFlag, QueryHelper, raw, RawQueryFragment, Reference, ReferenceKind, serialize, Utils, ValidationError, } from '@mikro-orm/core';
2
+ import { EntityMetadata, helper, inspect, isRaw, LoadStrategy, LockMode, PopulateHint, QueryFlag, QueryHelper, raw, RawQueryFragment, Reference, ReferenceKind, serialize, SUBQUERY_BRAND, Utils, ValidationError, } from '@mikro-orm/core';
3
3
  import { JoinType, QueryType } from './enums.js';
4
4
  import { QueryBuilderHelper } from './QueryBuilderHelper.js';
5
5
  import { CriteriaNodeFactory } from './CriteriaNodeFactory.js';
@@ -2675,3 +2675,5 @@ export class QueryBuilder {
2675
2675
  }
2676
2676
  }
2677
2677
  _a = QueryBuilder;
2678
+ // prototype-level brand recognized by `isSubquery()`, JSON payloads cannot forge it
2679
+ Object.defineProperty(QueryBuilder.prototype, SUBQUERY_BRAND, { value: true, writable: false, configurable: false });
@@ -1,4 +1,4 @@
1
- import { ALIAS_REPLACEMENT, ALIAS_REPLACEMENT_RE, ArrayType, JsonType, inspect, isRaw, LockMode, OptimisticLockError, QueryOperator, QueryOrderNumeric, raw, Raw, QueryHelper, ReferenceKind, Utils, ValidationError, } from '@mikro-orm/core';
1
+ import { ALIAS_REPLACEMENT, ALIAS_REPLACEMENT_RE, ArrayType, JsonType, inspect, isRaw, isSubquery, LockMode, OptimisticLockError, QueryOperator, QueryOrderNumeric, raw, Raw, QueryHelper, ReferenceKind, Utils, ValidationError, } from '@mikro-orm/core';
2
2
  import { EMBEDDABLE_ARRAY_OPS, JoinType, QueryType } from './enums.js';
3
3
  /** Captures the column name that follows the alias placeholder. */
4
4
  const QUALIFYING_ALIAS_RE = new RegExp(ALIAS_REPLACEMENT_RE + '(?=["\'`\\]]*\\.["\'`\\[]?([\\w$]+))', 'g');
@@ -613,7 +613,7 @@ export class QueryBuilderHelper {
613
613
  else {
614
614
  const opValue = value[op];
615
615
  const opValueIsRaw = isRaw(opValue);
616
- if (opValueIsRaw || typeof opValue?.toRaw === 'function') {
616
+ if (opValueIsRaw || isSubquery(opValue)) {
617
617
  const query = opValueIsRaw ? opValue : opValue.toRaw();
618
618
  const mappedKey = this.mapper(key, type, query, null);
619
619
  let sql = this.replaceAliases(query.sql);