@mikro-orm/sql 7.2.9-dev.0 → 7.2.9-dev.10
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.9-dev.
|
|
3
|
+
"version": "7.2.9-dev.10",
|
|
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.8"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@mikro-orm/core": "7.2.9-dev.
|
|
56
|
+
"@mikro-orm/core": "7.2.9-dev.10"
|
|
57
57
|
},
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": ">= 22.17.0"
|
package/query/QueryBuilder.d.ts
CHANGED
|
@@ -803,6 +803,11 @@ export declare class QueryBuilder<Entity extends object = AnyEntity, RootAlias e
|
|
|
803
803
|
* Use `method` to specify what kind of result you want to get (array/single/meta).
|
|
804
804
|
*/
|
|
805
805
|
execute<U = any>(method?: 'all' | 'get' | 'run', options?: ExecuteOptions | boolean): Promise<U>;
|
|
806
|
+
/**
|
|
807
|
+
* An update or delete with auto-joined conditions stays a select until `finalize()` wraps it,
|
|
808
|
+
* so read the same flags `wrapModifySubQuery()` uses.
|
|
809
|
+
*/
|
|
810
|
+
private getExecuteType;
|
|
806
811
|
private getConnection;
|
|
807
812
|
/**
|
|
808
813
|
* Executes the query and returns an async iterable (async generator) that yields results one by one.
|
package/query/QueryBuilder.js
CHANGED
|
@@ -1067,12 +1067,13 @@ export class QueryBuilder {
|
|
|
1067
1067
|
options = typeof options === 'boolean' ? { mapResults: options } : (options ?? {});
|
|
1068
1068
|
options.mergeResults ??= true;
|
|
1069
1069
|
options.mapResults ??= true;
|
|
1070
|
-
const
|
|
1070
|
+
const type = this.getExecuteType();
|
|
1071
|
+
const isRunType = [QueryType.INSERT, QueryType.UPDATE, QueryType.DELETE, QueryType.TRUNCATE].includes(type);
|
|
1071
1072
|
method ??= isRunType ? 'run' : 'all';
|
|
1072
1073
|
if (!this.connectionType && (isRunType || this.context)) {
|
|
1073
1074
|
this.connectionType = 'write';
|
|
1074
1075
|
}
|
|
1075
|
-
if (!this.#state.finalized && method === 'get' &&
|
|
1076
|
+
if (!this.#state.finalized && method === 'get' && type === QueryType.SELECT) {
|
|
1076
1077
|
this.limit(1);
|
|
1077
1078
|
}
|
|
1078
1079
|
const query = this.toQuery();
|
|
@@ -1130,6 +1131,19 @@ export class QueryBuilder {
|
|
|
1130
1131
|
await this.em?.storeCache(this.#state.cache, cached, mapped);
|
|
1131
1132
|
return mapped;
|
|
1132
1133
|
}
|
|
1134
|
+
/**
|
|
1135
|
+
* An update or delete with auto-joined conditions stays a select until `finalize()` wraps it,
|
|
1136
|
+
* so read the same flags `wrapModifySubQuery()` uses.
|
|
1137
|
+
*/
|
|
1138
|
+
getExecuteType() {
|
|
1139
|
+
if (this.#state.flags.has(QueryFlag.UPDATE_SUB_QUERY)) {
|
|
1140
|
+
return QueryType.UPDATE;
|
|
1141
|
+
}
|
|
1142
|
+
if (this.#state.flags.has(QueryFlag.DELETE_SUB_QUERY)) {
|
|
1143
|
+
return QueryType.DELETE;
|
|
1144
|
+
}
|
|
1145
|
+
return this.type;
|
|
1146
|
+
}
|
|
1133
1147
|
getConnection() {
|
|
1134
1148
|
const write = !this.platform.getConfig().get('preferReadReplicas');
|
|
1135
1149
|
const type = this.connectionType || (write ? 'write' : 'read');
|
|
@@ -92,6 +92,7 @@ export declare class SchemaComparator {
|
|
|
92
92
|
private diffPolicy;
|
|
93
93
|
parseJsonDefault(defaultValue?: string | null): Dictionary | string | null;
|
|
94
94
|
private parseDecimalDefault;
|
|
95
|
+
private parseBigIntDefault;
|
|
95
96
|
hasSameDefaultValue(from: Column, to: Column): boolean;
|
|
96
97
|
private mapColumnToProperty;
|
|
97
98
|
private log;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ArrayType, BooleanType, DateTimeType, DecimalType, inspect, JsonType, parseJsonSafe, Utils, } from '@mikro-orm/core';
|
|
1
|
+
import { ArrayType, BigIntType, BooleanType, DateTimeType, DecimalType, inspect, JsonType, parseJsonSafe, Utils, } from '@mikro-orm/core';
|
|
2
2
|
import { DatabaseTable } from './DatabaseTable.js';
|
|
3
3
|
import { diffPartitioning } from './partitioning.js';
|
|
4
4
|
/**
|
|
@@ -1098,6 +1098,10 @@ export class SchemaComparator {
|
|
|
1098
1098
|
const value = +('' + defaultValue).replace(/^'(.+)'$/, '$1');
|
|
1099
1099
|
return Number.isFinite(value) ? value : null;
|
|
1100
1100
|
}
|
|
1101
|
+
parseBigIntDefault(defaultValue) {
|
|
1102
|
+
const value = ('' + defaultValue).replace(/^'(.+)'$/, '$1');
|
|
1103
|
+
return /^-?\d+$/.test(value) ? BigInt(value) : null;
|
|
1104
|
+
}
|
|
1101
1105
|
hasSameDefaultValue(from, to) {
|
|
1102
1106
|
if (from.default == null ||
|
|
1103
1107
|
from.default.toString().toLowerCase() === 'null' ||
|
|
@@ -1133,6 +1137,14 @@ export class SchemaComparator {
|
|
|
1133
1137
|
this.#platform.formatDecimal(defaultValueTo, to.scale));
|
|
1134
1138
|
}
|
|
1135
1139
|
}
|
|
1140
|
+
// metadata quotes bigint defaults (`'0'`) while mysql reports them bare
|
|
1141
|
+
if (to.mappedType instanceof BigIntType) {
|
|
1142
|
+
const defaultValueFrom = this.parseBigIntDefault(from.default);
|
|
1143
|
+
const defaultValueTo = this.parseBigIntDefault(to.default);
|
|
1144
|
+
if (defaultValueFrom != null && defaultValueTo != null) {
|
|
1145
|
+
return defaultValueFrom === defaultValueTo;
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1136
1148
|
if (from.default && to.default) {
|
|
1137
1149
|
return from.default.toString().toLowerCase() === to.default.toString().toLowerCase();
|
|
1138
1150
|
}
|