@mikro-orm/knex 5.7.15-dev.35 → 5.7.15-dev.37
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
CHANGED
|
@@ -335,7 +335,7 @@ class AbstractSqlDriver extends core_1.DatabaseDriver {
|
|
|
335
335
|
const uniqueFields = core_1.Utils.isPlainObject(where) ? Object.keys(where) : meta.primaryKeys;
|
|
336
336
|
/* istanbul ignore next */
|
|
337
337
|
qb.insert(data)
|
|
338
|
-
.onConflict(uniqueFields
|
|
338
|
+
.onConflict(uniqueFields)
|
|
339
339
|
.merge(Object.keys(data).filter(f => !uniqueFields.includes(f)))
|
|
340
340
|
.returning(meta?.comparableProps.filter(p => !p.lazy && !p.embeddable && !(p.name in data)).map(p => p.name) ?? '*');
|
|
341
341
|
}
|
|
@@ -357,7 +357,7 @@ class AbstractSqlDriver extends core_1.DatabaseDriver {
|
|
|
357
357
|
const uniqueFields = core_1.Utils.isPlainObject(where[0]) ? Object.keys(where[0]) : meta.primaryKeys;
|
|
358
358
|
const qb = this.createQueryBuilder(entityName, options.ctx, 'write', options.convertCustomTypes).withSchema(this.getSchemaName(meta, options));
|
|
359
359
|
qb.insert(data)
|
|
360
|
-
.onConflict(uniqueFields
|
|
360
|
+
.onConflict(uniqueFields)
|
|
361
361
|
.merge(Object.keys(data[0]).filter(f => !uniqueFields.includes(f)))
|
|
362
362
|
.returning(meta.comparableProps.filter(p => !p.lazy && !p.embeddable && !(p.name in data[0])).map(p => p.name) ?? '*');
|
|
363
363
|
return qb.execute('run', false);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/knex",
|
|
3
|
-
"version": "5.7.15-dev.
|
|
3
|
+
"version": "5.7.15-dev.37",
|
|
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,9 +66,9 @@
|
|
|
66
66
|
"@mikro-orm/core": "^5.7.14"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
|
-
"@mikro-orm/core": "~5.7.15-dev.
|
|
70
|
-
"@mikro-orm/entity-generator": "~5.7.15-dev.
|
|
71
|
-
"@mikro-orm/migrations": "~5.7.15-dev.
|
|
69
|
+
"@mikro-orm/core": "~5.7.15-dev.37",
|
|
70
|
+
"@mikro-orm/entity-generator": "~5.7.15-dev.37",
|
|
71
|
+
"@mikro-orm/migrations": "~5.7.15-dev.37",
|
|
72
72
|
"better-sqlite3": "*",
|
|
73
73
|
"mssql": "*",
|
|
74
74
|
"mysql": "*",
|
package/query/QueryBuilder.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ export declare class QueryBuilder<T extends object = AnyEntity> {
|
|
|
34
34
|
private readonly context?;
|
|
35
35
|
private connectionType?;
|
|
36
36
|
private readonly em?;
|
|
37
|
-
get mainAlias(): Alias
|
|
37
|
+
get mainAlias(): Alias<T>;
|
|
38
38
|
get alias(): string;
|
|
39
39
|
get helper(): QueryBuilderHelper;
|
|
40
40
|
/** @internal */
|
package/query/QueryBuilder.js
CHANGED
|
@@ -244,9 +244,16 @@ class QueryBuilder {
|
|
|
244
244
|
return this;
|
|
245
245
|
}
|
|
246
246
|
onConflict(fields = []) {
|
|
247
|
+
const meta = this.mainAlias.metadata;
|
|
247
248
|
this.ensureNotFinalized();
|
|
248
|
-
this._onConflict
|
|
249
|
-
this._onConflict.push({
|
|
249
|
+
this._onConflict ?? (this._onConflict = []);
|
|
250
|
+
this._onConflict.push({
|
|
251
|
+
fields: core_1.Utils.asArray(fields).flatMap(f => {
|
|
252
|
+
const key = f.toString();
|
|
253
|
+
/* istanbul ignore next */
|
|
254
|
+
return meta.properties[key]?.fieldNames ?? [key];
|
|
255
|
+
}),
|
|
256
|
+
});
|
|
250
257
|
return this;
|
|
251
258
|
}
|
|
252
259
|
ignore() {
|
|
@@ -16,7 +16,7 @@ export declare class QueryBuilderHelper {
|
|
|
16
16
|
private readonly driver;
|
|
17
17
|
private readonly platform;
|
|
18
18
|
private readonly metadata;
|
|
19
|
-
constructor(entityName: string, alias: string, aliasMap: Dictionary<Alias
|
|
19
|
+
constructor(entityName: string, alias: string, aliasMap: Dictionary<Alias<any>>, subQueries: Dictionary<string>, knex: Knex, driver: AbstractSqlDriver);
|
|
20
20
|
mapper(field: string | Knex.Raw, type?: QueryType): string;
|
|
21
21
|
mapper(field: string | Knex.Raw, type?: QueryType, value?: any, alias?: string | null): string;
|
|
22
22
|
processData(data: Dictionary, convertCustomTypes: boolean, multi?: boolean): any;
|
|
@@ -61,9 +61,9 @@ export declare class QueryBuilderHelper {
|
|
|
61
61
|
isTableNameAliasRequired(type?: QueryType): boolean;
|
|
62
62
|
private mapData;
|
|
63
63
|
}
|
|
64
|
-
export interface Alias {
|
|
64
|
+
export interface Alias<T> {
|
|
65
65
|
aliasName: string;
|
|
66
66
|
entityName: string;
|
|
67
|
-
metadata?: EntityMetadata
|
|
67
|
+
metadata?: EntityMetadata<T>;
|
|
68
68
|
subQuery?: Knex.QueryBuilder;
|
|
69
69
|
}
|
|
@@ -17,6 +17,7 @@ export declare class DatabaseTable {
|
|
|
17
17
|
constructor(platform: AbstractSqlPlatform, name: string, schema?: string | undefined);
|
|
18
18
|
getColumns(): Column[];
|
|
19
19
|
getColumn(name: string): Column | undefined;
|
|
20
|
+
removeColumn(name: string): void;
|
|
20
21
|
getIndexes(): Index[];
|
|
21
22
|
getChecks(): Check[];
|
|
22
23
|
init(cols: Column[], indexes: Index[] | undefined, checks: Check<unknown>[] | undefined, pks: string[], fks?: Dictionary<ForeignKey>, enums?: Dictionary<string[]>): void;
|