@mikro-orm/knex 6.0.0-dev.169 → 6.0.0-dev.170
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/knex",
|
|
3
|
-
"version": "6.0.0-dev.
|
|
3
|
+
"version": "6.0.0-dev.170",
|
|
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
|
"main": "index.js",
|
|
6
6
|
"module": "index.mjs",
|
|
@@ -66,6 +66,6 @@
|
|
|
66
66
|
"@mikro-orm/core": "^5.9.2"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
|
-
"@mikro-orm/core": "6.0.0-dev.
|
|
69
|
+
"@mikro-orm/core": "6.0.0-dev.170"
|
|
70
70
|
}
|
|
71
71
|
}
|
package/schema/DatabaseSchema.js
CHANGED
|
@@ -73,7 +73,7 @@ class DatabaseSchema {
|
|
|
73
73
|
table.comment = meta.comment;
|
|
74
74
|
meta.props
|
|
75
75
|
.filter(prop => this.shouldHaveColumn(meta, prop))
|
|
76
|
-
.forEach(prop => table.addColumnFromProperty(prop, meta));
|
|
76
|
+
.forEach(prop => table.addColumnFromProperty(prop, meta, config));
|
|
77
77
|
meta.indexes.forEach(index => table.addIndex(meta, index, 'index'));
|
|
78
78
|
meta.uniques.forEach(index => table.addIndex(meta, index, 'unique'));
|
|
79
79
|
table.addIndex(meta, { properties: meta.props.filter(prop => prop.primary).map(prop => prop.name) }, 'primary');
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Dictionary, type EntityMetadata, type EntityProperty, type NamingStrategy } from '@mikro-orm/core';
|
|
1
|
+
import { type Dictionary, type EntityMetadata, type EntityProperty, type NamingStrategy, type Configuration } from '@mikro-orm/core';
|
|
2
2
|
import type { SchemaHelper } from './SchemaHelper';
|
|
3
3
|
import type { CheckDef, Column, ForeignKey, IndexDef } from '../typings';
|
|
4
4
|
import type { AbstractSqlPlatform } from '../AbstractSqlPlatform';
|
|
@@ -23,7 +23,7 @@ export declare class DatabaseTable {
|
|
|
23
23
|
getChecks(): CheckDef[];
|
|
24
24
|
init(cols: Column[], indexes: IndexDef[] | undefined, checks: CheckDef<unknown>[] | undefined, pks: string[], fks?: Dictionary<ForeignKey>, enums?: Dictionary<string[]>): void;
|
|
25
25
|
addColumn(column: Column): void;
|
|
26
|
-
addColumnFromProperty(prop: EntityProperty, meta: EntityMetadata): void;
|
|
26
|
+
addColumnFromProperty(prop: EntityProperty, meta: EntityMetadata, config: Configuration): void;
|
|
27
27
|
private getIndexName;
|
|
28
28
|
getEntityDeclaration(namingStrategy: NamingStrategy, schemaHelper: SchemaHelper): EntityMetadata;
|
|
29
29
|
/**
|
package/schema/DatabaseTable.js
CHANGED
|
@@ -57,7 +57,7 @@ class DatabaseTable {
|
|
|
57
57
|
addColumn(column) {
|
|
58
58
|
this.columns[column.name] = column;
|
|
59
59
|
}
|
|
60
|
-
addColumnFromProperty(prop, meta) {
|
|
60
|
+
addColumnFromProperty(prop, meta, config) {
|
|
61
61
|
prop.fieldNames.forEach((field, idx) => {
|
|
62
62
|
const type = prop.enum ? 'enum' : prop.columnTypes[idx];
|
|
63
63
|
const mappedType = this.platform.getMappedType(type);
|
|
@@ -105,7 +105,7 @@ class DatabaseTable {
|
|
|
105
105
|
});
|
|
106
106
|
if ([core_1.ReferenceKind.MANY_TO_ONE, core_1.ReferenceKind.ONE_TO_ONE].includes(prop.kind)) {
|
|
107
107
|
const constraintName = this.getIndexName(true, prop.fieldNames, 'foreign');
|
|
108
|
-
let schema = prop.targetMeta.schema === '*' ? this.schema : prop.targetMeta.schema ?? this.
|
|
108
|
+
let schema = prop.targetMeta.schema === '*' ? this.schema : (prop.targetMeta.schema ?? config.get('schema', this.platform.getDefaultSchemaName()));
|
|
109
109
|
if (prop.referencedTableName.includes('.')) {
|
|
110
110
|
schema = undefined;
|
|
111
111
|
}
|
|
@@ -215,7 +215,7 @@ class SqlSchemaGenerator extends core_1.AbstractSchemaGenerator {
|
|
|
215
215
|
if (schema && schemaName === '*') {
|
|
216
216
|
return `${schema}.${referencedTableName.replace(/^\*\./, '')}`;
|
|
217
217
|
}
|
|
218
|
-
if (schemaName === this.platform.getDefaultSchemaName()) {
|
|
218
|
+
if (!schemaName || schemaName === this.platform.getDefaultSchemaName()) {
|
|
219
219
|
return tableName;
|
|
220
220
|
}
|
|
221
221
|
return `${schemaName}.${tableName}`;
|