@mikro-orm/mariadb 7.1.0-dev.2 → 7.1.0-dev.20
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/MariaDbSchemaHelper.d.ts +6 -0
- package/MariaDbSchemaHelper.js +16 -0
- package/package.json +4 -4
package/MariaDbSchemaHelper.d.ts
CHANGED
|
@@ -2,6 +2,12 @@ import { type AbstractSqlConnection, type CheckDef, type Column, type IndexDef,
|
|
|
2
2
|
import { type Dictionary, type Transaction, type Type } from '@mikro-orm/core';
|
|
3
3
|
/** Schema introspection helper for MariaDB. */
|
|
4
4
|
export declare class MariaDbSchemaHelper extends MySqlSchemaHelper {
|
|
5
|
+
/**
|
|
6
|
+
* MariaDB does not support inline expression indexes the way MySQL 8.0+ does, so the
|
|
7
|
+
* `(CASE WHEN <pred> THEN <col> END)` emulation MikroORM uses on MySQL would error out.
|
|
8
|
+
* For partial indexes on MariaDB, define a virtual generated column and index that instead.
|
|
9
|
+
*/
|
|
10
|
+
protected getIndexColumns(index: IndexDef): string;
|
|
5
11
|
protected appendMySqlIndexSuffix(sql: string, index: IndexDef): string;
|
|
6
12
|
loadInformationSchema(schema: DatabaseSchema, connection: AbstractSqlConnection, tables: Table[], schemas?: string[], ctx?: Transaction): Promise<void>;
|
|
7
13
|
getAllIndexes(connection: AbstractSqlConnection, tables: Table[], ctx?: Transaction): Promise<Dictionary<IndexDef[]>>;
|
package/MariaDbSchemaHelper.js
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
import { MySqlSchemaHelper, } from '@mikro-orm/mysql';
|
|
2
2
|
/** Schema introspection helper for MariaDB. */
|
|
3
3
|
export class MariaDbSchemaHelper extends MySqlSchemaHelper {
|
|
4
|
+
/**
|
|
5
|
+
* MariaDB does not support inline expression indexes the way MySQL 8.0+ does, so the
|
|
6
|
+
* `(CASE WHEN <pred> THEN <col> END)` emulation MikroORM uses on MySQL would error out.
|
|
7
|
+
* For partial indexes on MariaDB, define a virtual generated column and index that instead.
|
|
8
|
+
*/
|
|
9
|
+
getIndexColumns(index) {
|
|
10
|
+
if (index.where) {
|
|
11
|
+
throw new Error(`Index '${index.keyName}': partial indexes (\`where\`) are not supported on MariaDB. ` +
|
|
12
|
+
`MariaDB does not support inline expression indexes; define a virtual generated column with the predicate and index that column instead.`);
|
|
13
|
+
}
|
|
14
|
+
return super.getIndexColumns(index);
|
|
15
|
+
}
|
|
4
16
|
appendMySqlIndexSuffix(sql, index) {
|
|
5
17
|
// MariaDB uses IGNORED instead of MySQL's INVISIBLE keyword
|
|
6
18
|
if (index.invisible) {
|
|
@@ -24,11 +36,15 @@ export class MariaDbSchemaHelper extends MySqlSchemaHelper {
|
|
|
24
36
|
const checks = await this.getAllChecks(connection, tables, ctx, columns);
|
|
25
37
|
const fks = await this.getAllForeignKeys(connection, tables, ctx);
|
|
26
38
|
const enums = await this.getAllEnumDefinitions(connection, tables, ctx);
|
|
39
|
+
const triggers = await this.getAllTriggers(connection, tables);
|
|
27
40
|
for (const t of tables) {
|
|
28
41
|
const key = this.getTableKey(t);
|
|
29
42
|
const table = schema.addTable(t.table_name, t.schema_name, t.table_comment);
|
|
30
43
|
const pks = await this.getPrimaryKeys(connection, indexes[key], table.name, table.schema);
|
|
31
44
|
table.init(columns[key], indexes[key], checks[key], pks, fks[key], enums[key]);
|
|
45
|
+
if (triggers[key]) {
|
|
46
|
+
table.setTriggers(triggers[key]);
|
|
47
|
+
}
|
|
32
48
|
}
|
|
33
49
|
}
|
|
34
50
|
async getAllIndexes(connection, tables, ctx) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/mariadb",
|
|
3
|
-
"version": "7.1.0-dev.
|
|
3
|
+
"version": "7.1.0-dev.20",
|
|
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,14 +47,14 @@
|
|
|
47
47
|
"copy": "node ../../scripts/copy.mjs"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@mikro-orm/mysql": "7.1.0-dev.
|
|
50
|
+
"@mikro-orm/mysql": "7.1.0-dev.20",
|
|
51
51
|
"kysely": "0.28.16"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@mikro-orm/core": "^7.0.
|
|
54
|
+
"@mikro-orm/core": "^7.0.12"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"@mikro-orm/core": "7.1.0-dev.
|
|
57
|
+
"@mikro-orm/core": "7.1.0-dev.20"
|
|
58
58
|
},
|
|
59
59
|
"engines": {
|
|
60
60
|
"node": ">= 22.17.0"
|