@mikro-orm/mariadb 7.1.0-dev.21 → 7.1.0-dev.23
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.js +26 -16
- package/package.json +4 -4
package/MariaDbSchemaHelper.js
CHANGED
|
@@ -40,6 +40,7 @@ export class MariaDbSchemaHelper extends MySqlSchemaHelper {
|
|
|
40
40
|
for (const t of tables) {
|
|
41
41
|
const key = this.getTableKey(t);
|
|
42
42
|
const table = schema.addTable(t.table_name, t.schema_name, t.table_comment);
|
|
43
|
+
table.collation = t.table_collation ?? undefined;
|
|
43
44
|
const pks = await this.getPrimaryKeys(connection, indexes[key], table.name, table.schema);
|
|
44
45
|
table.init(columns[key], indexes[key], checks[key], pks, fks[key], enums[key]);
|
|
45
46
|
if (triggers[key]) {
|
|
@@ -95,22 +96,25 @@ export class MariaDbSchemaHelper extends MySqlSchemaHelper {
|
|
|
95
96
|
return ret;
|
|
96
97
|
}
|
|
97
98
|
async getAllColumns(connection, tables, ctx) {
|
|
98
|
-
const sql = `select table_name as table_name,
|
|
99
|
-
nullif(table_schema, schema()) as schema_name,
|
|
100
|
-
column_name as column_name,
|
|
101
|
-
column_default as column_default,
|
|
102
|
-
nullif(column_comment, '') as column_comment,
|
|
103
|
-
is_nullable as is_nullable,
|
|
104
|
-
data_type as data_type,
|
|
105
|
-
column_type as column_type,
|
|
106
|
-
column_key as column_key,
|
|
107
|
-
extra as extra,
|
|
108
|
-
generation_expression as generation_expression,
|
|
109
|
-
numeric_precision as numeric_precision,
|
|
110
|
-
numeric_scale as numeric_scale,
|
|
111
|
-
ifnull(datetime_precision, character_maximum_length) length
|
|
112
|
-
|
|
113
|
-
|
|
99
|
+
const sql = `select c.table_name as table_name,
|
|
100
|
+
nullif(c.table_schema, schema()) as schema_name,
|
|
101
|
+
c.column_name as column_name,
|
|
102
|
+
c.column_default as column_default,
|
|
103
|
+
nullif(c.column_comment, '') as column_comment,
|
|
104
|
+
c.is_nullable as is_nullable,
|
|
105
|
+
c.data_type as data_type,
|
|
106
|
+
c.column_type as column_type,
|
|
107
|
+
c.column_key as column_key,
|
|
108
|
+
c.extra as extra,
|
|
109
|
+
c.generation_expression as generation_expression,
|
|
110
|
+
c.numeric_precision as numeric_precision,
|
|
111
|
+
c.numeric_scale as numeric_scale,
|
|
112
|
+
ifnull(c.datetime_precision, c.character_maximum_length) length,
|
|
113
|
+
nullif(c.collation_name, t.table_collation) as collation_name
|
|
114
|
+
from information_schema.columns c
|
|
115
|
+
join information_schema.tables t on t.table_schema = c.table_schema and t.table_name = c.table_name
|
|
116
|
+
where c.table_schema = database() and c.table_name in (${tables.map(t => this.platform.quoteValue(t.table_name)).join(', ')})
|
|
117
|
+
order by c.ordinal_position`;
|
|
114
118
|
const allColumns = await connection.execute(sql, [], 'all', ctx);
|
|
115
119
|
const str = (val) => (val != null ? '' + val : val);
|
|
116
120
|
const extra = (val) => val.replace(/auto_increment|default_generated|(stored|virtual) generated/i, '').trim() || undefined;
|
|
@@ -142,6 +146,7 @@ export class MariaDbSchemaHelper extends MySqlSchemaHelper {
|
|
|
142
146
|
precision: col.numeric_precision,
|
|
143
147
|
scale: col.numeric_scale,
|
|
144
148
|
comment: col.column_comment,
|
|
149
|
+
collation: col.collation_name ?? undefined,
|
|
145
150
|
extra: extra(col.extra),
|
|
146
151
|
generated,
|
|
147
152
|
});
|
|
@@ -160,6 +165,11 @@ export class MariaDbSchemaHelper extends MySqlSchemaHelper {
|
|
|
160
165
|
col.type = 'json';
|
|
161
166
|
col.mappedType = this.platform.getMappedType('json');
|
|
162
167
|
delete col.length;
|
|
168
|
+
// MariaDB JSON columns are stored as LONGTEXT with `utf8mb4_bin` regardless of the
|
|
169
|
+
// table default, so introspection picks up a non-default `collation_name`. After the
|
|
170
|
+
// rewrite to `type = 'json'`, the column has no user-facing collation — drop the
|
|
171
|
+
// introspected value so the comparator doesn't emit a phantom MODIFY on every diff.
|
|
172
|
+
col.collation = undefined;
|
|
163
173
|
continue;
|
|
164
174
|
}
|
|
165
175
|
ret[key] ??= [];
|
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.23",
|
|
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.23",
|
|
51
51
|
"kysely": "0.28.16"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@mikro-orm/core": "^7.0.
|
|
54
|
+
"@mikro-orm/core": "^7.0.13"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"@mikro-orm/core": "7.1.0-dev.
|
|
57
|
+
"@mikro-orm/core": "7.1.0-dev.23"
|
|
58
58
|
},
|
|
59
59
|
"engines": {
|
|
60
60
|
"node": ">= 22.17.0"
|