@mikro-orm/sql 7.2.7-dev.7 → 7.2.7-dev.8
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type EntityProperty, type IsolationLevel } from '@mikro-orm/core';
|
|
1
|
+
import { type EntityMetadata, type EntityProperty, type IsolationLevel } from '@mikro-orm/core';
|
|
2
2
|
import { AbstractSqlPlatform } from '../../AbstractSqlPlatform.js';
|
|
3
3
|
import { SqliteNativeQueryBuilder } from './SqliteNativeQueryBuilder.js';
|
|
4
4
|
import { SqliteSchemaHelper } from './SqliteSchemaHelper.js';
|
|
@@ -74,6 +74,7 @@ export declare class SqlitePlatform extends AbstractSqlPlatform {
|
|
|
74
74
|
*/
|
|
75
75
|
supportsSchemas(): boolean;
|
|
76
76
|
getDefaultSchemaName(): string | undefined;
|
|
77
|
+
validateMetadata(meta: EntityMetadata): void;
|
|
77
78
|
getFullTextWhereClause(): string;
|
|
78
79
|
escape(value: any): string;
|
|
79
80
|
convertVersionValue(value: Date | number, prop: EntityProperty): number | {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MetadataError } from '@mikro-orm/core';
|
|
1
2
|
import { AbstractSqlPlatform } from '../../AbstractSqlPlatform.js';
|
|
2
3
|
import { SqliteNativeQueryBuilder } from './SqliteNativeQueryBuilder.js';
|
|
3
4
|
import { SqliteSchemaHelper } from './SqliteSchemaHelper.js';
|
|
@@ -110,6 +111,14 @@ export class SqlitePlatform extends AbstractSqlPlatform {
|
|
|
110
111
|
// Return 'main' only when schema support is active (i.e., databases are attached)
|
|
111
112
|
return this.supportsSchemas() ? 'main' : undefined;
|
|
112
113
|
}
|
|
114
|
+
validateMetadata(meta) {
|
|
115
|
+
super.validateMetadata(meta);
|
|
116
|
+
// `main` always exists and `*` resolves at runtime; anything else fails later as `unknown database` unless attached
|
|
117
|
+
const attached = this.config.get('attachDatabases')?.some(db => db.name === meta.schema);
|
|
118
|
+
if (meta.schema && !['main', '*'].includes(meta.schema) && !attached) {
|
|
119
|
+
throw new MetadataError(`Entity ${meta.className} declares schema '${meta.schema}', but SQLite cannot address it: attach it via \`attachDatabases\` or remove the schema in \`discovery.onMetadata\` when sharing entities between drivers`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
113
122
|
getFullTextWhereClause() {
|
|
114
123
|
return `:column: match :query`;
|
|
115
124
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/sql",
|
|
3
|
-
"version": "7.2.7-dev.
|
|
3
|
+
"version": "7.2.7-dev.8",
|
|
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.
|
|
56
|
+
"@mikro-orm/core": "7.2.7-dev.8"
|
|
57
57
|
},
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": ">= 22.17.0"
|
package/query/QueryBuilder.d.ts
CHANGED
|
@@ -821,6 +821,7 @@ export declare class QueryBuilder<Entity extends object = AnyEntity, RootAlias e
|
|
|
821
821
|
* ```
|
|
822
822
|
*/
|
|
823
823
|
stream(options?: QBStreamOptions): AsyncIterableIterator<Loaded<Entity, Hint, Fields>>;
|
|
824
|
+
private convertStreamExceptions;
|
|
824
825
|
/**
|
|
825
826
|
* Alias for `qb.getResultList()`
|
|
826
827
|
*/
|
package/query/QueryBuilder.js
CHANGED
|
@@ -1080,12 +1080,19 @@ export class QueryBuilder {
|
|
|
1080
1080
|
const conn = this.getConnection();
|
|
1081
1081
|
// outside a transaction, wrap in a short implicit one so RLS `set local` session context applies (no-op when unset)
|
|
1082
1082
|
const sessionContext = this.context ? undefined : this.em?.getTransactionSessionContext();
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1083
|
+
let res;
|
|
1084
|
+
// a QueryBuilder used directly must honour the same `convertException` contract as the driver methods
|
|
1085
|
+
try {
|
|
1086
|
+
res = await (sessionContext
|
|
1087
|
+
? conn.transactional(trx => conn.execute(query.sql, query.params, method, trx, loggerContext), {
|
|
1088
|
+
sessionContext,
|
|
1089
|
+
loggerContext,
|
|
1090
|
+
})
|
|
1091
|
+
: conn.execute(query.sql, query.params, method, this.context, loggerContext));
|
|
1092
|
+
}
|
|
1093
|
+
catch (e) {
|
|
1094
|
+
throw this.driver.convertException(e);
|
|
1095
|
+
}
|
|
1089
1096
|
const meta = this.mainAlias.meta;
|
|
1090
1097
|
if (!options.mapResults || !meta) {
|
|
1091
1098
|
await this.em?.storeCache(this.#state.cache, cached, res);
|
|
@@ -1146,7 +1153,7 @@ export class QueryBuilder {
|
|
|
1146
1153
|
const chunkSize = options.chunkSize ?? 100;
|
|
1147
1154
|
const query = this.toQuery();
|
|
1148
1155
|
const loggerContext = { id: this.em?.id, ...this.loggerContext, ...this.#abortOptions };
|
|
1149
|
-
const res = this.getConnection().stream(query.sql, query.params, this.context, loggerContext, chunkSize);
|
|
1156
|
+
const res = this.convertStreamExceptions(this.getConnection().stream(query.sql, query.params, this.context, loggerContext, chunkSize));
|
|
1150
1157
|
const meta = this.mainAlias.meta;
|
|
1151
1158
|
if (options.rawResults || !meta) {
|
|
1152
1159
|
yield* res;
|
|
@@ -1180,6 +1187,14 @@ export class QueryBuilder {
|
|
|
1180
1187
|
}
|
|
1181
1188
|
}
|
|
1182
1189
|
}
|
|
1190
|
+
async *convertStreamExceptions(res) {
|
|
1191
|
+
try {
|
|
1192
|
+
yield* res;
|
|
1193
|
+
}
|
|
1194
|
+
catch (e) {
|
|
1195
|
+
throw this.driver.convertException(e);
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1183
1198
|
/**
|
|
1184
1199
|
* Alias for `qb.getResultList()`
|
|
1185
1200
|
*/
|