@mikro-orm/sql 7.1.0-dev.26 → 7.1.0-dev.28
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/AbstractSqlDriver.js +3 -1
- package/AbstractSqlPlatform.d.ts +2 -1
- package/AbstractSqlPlatform.js +9 -4
- package/SqlMikroORM.d.ts +23 -0
- package/SqlMikroORM.js +23 -0
- package/dialects/postgresql/BasePostgreSqlPlatform.js +4 -3
- package/index.d.ts +2 -0
- package/index.js +2 -0
- package/package.json +4 -4
package/AbstractSqlDriver.js
CHANGED
|
@@ -57,7 +57,9 @@ export class AbstractSqlDriver extends DatabaseDriver {
|
|
|
57
57
|
const populate = this.autoJoinOneToOneOwner(meta, options.populate, options.fields);
|
|
58
58
|
const joinedProps = this.joinedProps(meta, populate, options);
|
|
59
59
|
const schema = this.getSchemaName(meta, options);
|
|
60
|
-
const qb = this.createQueryBuilder(meta.class, options.ctx, connectionType, false, options.logging, undefined, options.em)
|
|
60
|
+
const qb = this.createQueryBuilder(meta.class, options.ctx, connectionType, false, options.logging, undefined, options.em)
|
|
61
|
+
.withSchema(schema)
|
|
62
|
+
.cache(false);
|
|
61
63
|
const fields = this.buildFields(meta, populate, joinedProps, qb, qb.alias, options, schema);
|
|
62
64
|
const orderBy = this.buildOrderBy(qb, meta, populate, options);
|
|
63
65
|
const populateWhere = this.buildPopulateWhere(meta, joinedProps, options);
|
package/AbstractSqlPlatform.d.ts
CHANGED
|
@@ -30,7 +30,8 @@ export declare abstract class AbstractSqlPlatform extends Platform {
|
|
|
30
30
|
getSearchJsonPropertyKey(path: string[], type: string, aliased: boolean, value?: unknown): string | RawQueryFragment;
|
|
31
31
|
/**
|
|
32
32
|
* Quotes a key for use inside a JSON path expression (e.g. `$.key`).
|
|
33
|
-
* Simple alphanumeric keys are left unquoted; others are wrapped in double quotes
|
|
33
|
+
* Simple alphanumeric keys are left unquoted; others are wrapped in double quotes
|
|
34
|
+
* with embedded `\` and `"` escaped per the JSON path string syntax.
|
|
34
35
|
* @internal
|
|
35
36
|
*/
|
|
36
37
|
quoteJsonKey(key: string): string;
|
package/AbstractSqlPlatform.js
CHANGED
|
@@ -66,18 +66,23 @@ export class AbstractSqlPlatform extends Platform {
|
|
|
66
66
|
}
|
|
67
67
|
getSearchJsonPropertyKey(path, type, aliased, value) {
|
|
68
68
|
const [a, ...b] = path;
|
|
69
|
+
const jsonPath = this.quoteValue(`$.${b.map(this.quoteJsonKey).join('.')}`);
|
|
69
70
|
if (aliased) {
|
|
70
|
-
return raw(alias => `json_extract(${this.quoteIdentifier(`${alias}.${a}`)},
|
|
71
|
+
return raw(alias => `json_extract(${this.quoteIdentifier(`${alias}.${a}`)}, ${jsonPath})`);
|
|
71
72
|
}
|
|
72
|
-
return raw(`json_extract(${this.quoteIdentifier(a)},
|
|
73
|
+
return raw(`json_extract(${this.quoteIdentifier(a)}, ${jsonPath})`);
|
|
73
74
|
}
|
|
74
75
|
/**
|
|
75
76
|
* Quotes a key for use inside a JSON path expression (e.g. `$.key`).
|
|
76
|
-
* Simple alphanumeric keys are left unquoted; others are wrapped in double quotes
|
|
77
|
+
* Simple alphanumeric keys are left unquoted; others are wrapped in double quotes
|
|
78
|
+
* with embedded `\` and `"` escaped per the JSON path string syntax.
|
|
77
79
|
* @internal
|
|
78
80
|
*/
|
|
79
81
|
quoteJsonKey(key) {
|
|
80
|
-
|
|
82
|
+
if (/^[a-z]\w*$/i.test(key)) {
|
|
83
|
+
return key;
|
|
84
|
+
}
|
|
85
|
+
return `"${key.replaceAll('\\', '\\\\').replaceAll('"', '\\"')}"`;
|
|
81
86
|
}
|
|
82
87
|
getJsonIndexDefinition(index) {
|
|
83
88
|
return index.columnNames.map(column => {
|
package/SqlMikroORM.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type AnyEntity, type EntityClass, type EntityManager, type EntityManagerType, type EntitySchema, type IDatabaseDriver, MikroORM, type Options } from '@mikro-orm/core';
|
|
2
|
+
import type { AbstractSqlDriver } from './AbstractSqlDriver.js';
|
|
3
|
+
import type { SqlEntityManager } from './SqlEntityManager.js';
|
|
4
|
+
/** Configuration options shared by all SQL drivers. */
|
|
5
|
+
export type SqlOptions<D extends AbstractSqlDriver = AbstractSqlDriver, EM extends SqlEntityManager<D> = SqlEntityManager<D>, Entities extends readonly (string | EntityClass<AnyEntity> | EntitySchema)[] = (string | EntityClass<AnyEntity> | EntitySchema)[]> = Partial<Options<D, EM, Entities>>;
|
|
6
|
+
/**
|
|
7
|
+
* Creates a type-safe configuration object for any SQL driver. The driver class
|
|
8
|
+
* must be passed via `options.driver` (e.g. `SqliteDriver`, `MySqlDriver`, …).
|
|
9
|
+
*/
|
|
10
|
+
export declare function defineSqlConfig<D extends AbstractSqlDriver = AbstractSqlDriver, EM extends SqlEntityManager<D> = SqlEntityManager<D>, Entities extends readonly (string | EntityClass<AnyEntity> | EntitySchema)[] = (string | EntityClass<AnyEntity> | EntitySchema)[]>(options: Partial<Options<D, EM, Entities>>): Partial<Options<D, EM, Entities>>;
|
|
11
|
+
/**
|
|
12
|
+
* Generic entry point for SQL drivers. Use this when consuming `@mikro-orm/sql`
|
|
13
|
+
* directly with a Kysely dialect; for the bundled driver packages prefer
|
|
14
|
+
* `@mikro-orm/sqlite`, `@mikro-orm/postgresql`, etc.
|
|
15
|
+
*
|
|
16
|
+
* @inheritDoc
|
|
17
|
+
*/
|
|
18
|
+
export declare class SqlMikroORM<D extends AbstractSqlDriver = AbstractSqlDriver, EM extends SqlEntityManager<D> = SqlEntityManager<D>, Entities extends readonly (string | EntityClass<AnyEntity> | EntitySchema)[] = (string | EntityClass<AnyEntity> | EntitySchema)[]> extends MikroORM<D, EM, Entities> {
|
|
19
|
+
/**
|
|
20
|
+
* @inheritDoc
|
|
21
|
+
*/
|
|
22
|
+
static init<D extends IDatabaseDriver = AbstractSqlDriver, EM extends EntityManager<D> = D[typeof EntityManagerType] & EntityManager<D>, Entities extends readonly (string | EntityClass<AnyEntity> | EntitySchema)[] = (string | EntityClass<AnyEntity> | EntitySchema)[]>(options: Partial<Options<D, EM, Entities>>): Promise<MikroORM<D, EM, Entities>>;
|
|
23
|
+
}
|
package/SqlMikroORM.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { defineConfig, MikroORM, } from '@mikro-orm/core';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a type-safe configuration object for any SQL driver. The driver class
|
|
4
|
+
* must be passed via `options.driver` (e.g. `SqliteDriver`, `MySqlDriver`, …).
|
|
5
|
+
*/
|
|
6
|
+
export function defineSqlConfig(options) {
|
|
7
|
+
return defineConfig(options);
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Generic entry point for SQL drivers. Use this when consuming `@mikro-orm/sql`
|
|
11
|
+
* directly with a Kysely dialect; for the bundled driver packages prefer
|
|
12
|
+
* `@mikro-orm/sqlite`, `@mikro-orm/postgresql`, etc.
|
|
13
|
+
*
|
|
14
|
+
* @inheritDoc
|
|
15
|
+
*/
|
|
16
|
+
export class SqlMikroORM extends MikroORM {
|
|
17
|
+
/**
|
|
18
|
+
* @inheritDoc
|
|
19
|
+
*/
|
|
20
|
+
static async init(options) {
|
|
21
|
+
return super.init(options);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -246,9 +246,9 @@ export class BasePostgreSqlPlatform extends AbstractSqlPlatform {
|
|
|
246
246
|
lastOperator = '->';
|
|
247
247
|
}
|
|
248
248
|
if (path.length === 0) {
|
|
249
|
-
return cast(`${root}${lastOperator}
|
|
249
|
+
return cast(`${root}${lastOperator}${this.quoteValue(last)}`);
|
|
250
250
|
}
|
|
251
|
-
return cast(`${root}->${path.map(a => this.quoteValue(a)).join('->')}${lastOperator}
|
|
251
|
+
return cast(`${root}->${path.map(a => this.quoteValue(a)).join('->')}${lastOperator}${this.quoteValue(last)}`);
|
|
252
252
|
}
|
|
253
253
|
getJsonIndexDefinition(index) {
|
|
254
254
|
return index.columnNames.map(column => {
|
|
@@ -268,7 +268,8 @@ export class BasePostgreSqlPlatform extends AbstractSqlPlatform {
|
|
|
268
268
|
if (RawQueryFragment.isKnownFragment(id)) {
|
|
269
269
|
return super.quoteIdentifier(id);
|
|
270
270
|
}
|
|
271
|
-
|
|
271
|
+
const escaped = id.toString().replaceAll(quote, quote + quote);
|
|
272
|
+
return `${quote}${escaped.replace('.', `${quote}.${quote}`)}${quote}`;
|
|
272
273
|
}
|
|
273
274
|
pad(number, digits) {
|
|
274
275
|
return String(number).padStart(digits, '0');
|
package/index.d.ts
CHANGED
|
@@ -17,3 +17,5 @@ export type * from './typings.js';
|
|
|
17
17
|
export * from './plugin/index.js';
|
|
18
18
|
export { SqlEntityManager as EntityManager } from './SqlEntityManager.js';
|
|
19
19
|
export { SqlEntityRepository as EntityRepository } from './SqlEntityRepository.js';
|
|
20
|
+
export * from './SqlMikroORM.js';
|
|
21
|
+
export { SqlMikroORM as MikroORM, type SqlOptions as Options, defineSqlConfig as defineConfig } from './SqlMikroORM.js';
|
package/index.js
CHANGED
|
@@ -16,3 +16,5 @@ export * from './dialects/index.js';
|
|
|
16
16
|
export * from './plugin/index.js';
|
|
17
17
|
export { SqlEntityManager as EntityManager } from './SqlEntityManager.js';
|
|
18
18
|
export { SqlEntityRepository as EntityRepository } from './SqlEntityRepository.js';
|
|
19
|
+
export * from './SqlMikroORM.js';
|
|
20
|
+
export { SqlMikroORM as MikroORM, defineSqlConfig as defineConfig } from './SqlMikroORM.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/sql",
|
|
3
|
-
"version": "7.1.0-dev.
|
|
3
|
+
"version": "7.1.0-dev.28",
|
|
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",
|
|
@@ -47,13 +47,13 @@
|
|
|
47
47
|
"copy": "node ../../scripts/copy.mjs"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"kysely": "0.28.
|
|
50
|
+
"kysely": "0.28.17"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@mikro-orm/core": "^7.0.
|
|
53
|
+
"@mikro-orm/core": "^7.0.14"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@mikro-orm/core": "7.1.0-dev.
|
|
56
|
+
"@mikro-orm/core": "7.1.0-dev.28"
|
|
57
57
|
},
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": ">= 22.17.0"
|