@mikro-orm/knex 6.3.11-dev.17 → 6.3.11-dev.19

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.
@@ -261,7 +261,7 @@ class AbstractSqlDriver extends core_1.DatabaseDriver {
261
261
  else if (prop.runtimeType === 'Date') {
262
262
  const alias = `${relationAlias}__${prop.fieldNames[0]}`;
263
263
  const value = root[alias];
264
- if (tz && tz !== 'local' && typeof value === 'string' && !value.includes('+') && !value.endsWith('Z')) {
264
+ if (tz && tz !== 'local' && typeof value === 'string' && !value.includes('+') && value.lastIndexOf('-') < 11 && !value.endsWith('Z')) {
265
265
  relationPojo[prop.name] = this.platform.parseDate(value + tz);
266
266
  }
267
267
  else if (['string', 'number'].includes(typeof value)) {
@@ -562,7 +562,7 @@ class AbstractSqlDriver extends core_1.DatabaseDriver {
562
562
  params.push(value);
563
563
  };
564
564
  for (const key of keys) {
565
- const prop = meta.properties[key];
565
+ const prop = meta.properties[key] ?? meta.root.properties[key];
566
566
  prop.fieldNames.forEach((fieldName, fieldNameIdx) => {
567
567
  if (fields.has(fieldName)) {
568
568
  return;
@@ -1,11 +1,7 @@
1
1
  import BaseMySqlColumnCompiler from 'knex/lib/dialects/mysql/schema/mysql-columncompiler';
2
+ import type { IncrementOptions } from '../../typings';
2
3
  export declare class MySqlColumnCompiler extends BaseMySqlColumnCompiler {
3
- increments(this: any, options?: {
4
- primaryKey: boolean;
5
- unsigned: boolean;
6
- }): string;
7
- bigincrements(this: any, options?: {
8
- primaryKey: boolean;
9
- unsigned: boolean;
10
- }): string;
4
+ increments(options: IncrementOptions): string;
5
+ bigincrements(options: IncrementOptions): string;
6
+ private generateDDL;
11
7
  }
@@ -8,14 +8,19 @@ exports.MySqlColumnCompiler = void 0;
8
8
  const mysql_columncompiler_1 = __importDefault(require("knex/lib/dialects/mysql/schema/mysql-columncompiler"));
9
9
  class MySqlColumnCompiler extends mysql_columncompiler_1.default {
10
10
  // we need the old behaviour to be able to add auto_increment to a column that is already PK
11
- increments(options = { primaryKey: true, unsigned: true }) {
12
- const type = options.unsigned ? 'int unsigned' : 'int';
13
- return `${type} not null auto_increment` + (this.tableCompiler._canBeAddPrimaryKey(options) ? ' primary key' : '');
11
+ increments(options) {
12
+ return this.generateDDL(options);
14
13
  }
15
14
  /* istanbul ignore next */
16
- bigincrements(options = { primaryKey: true, unsigned: true }) {
17
- const type = options.unsigned ? 'bigint unsigned' : 'bigint';
18
- return `${type} not null auto_increment` + (this.tableCompiler._canBeAddPrimaryKey(options) ? ' primary key' : '');
15
+ bigincrements(options) {
16
+ return this.generateDDL(options);
17
+ }
18
+ generateDDL(options = {}) {
19
+ const { primaryKey = true, unsigned = true, type = 'int' } = options;
20
+ return type
21
+ + (unsigned ? ' unsigned' : '')
22
+ + ' not null auto_increment'
23
+ + (this.tableCompiler._canBeAddPrimaryKey({ primaryKey }) ? ' primary key' : '');
19
24
  }
20
25
  }
21
26
  exports.MySqlColumnCompiler = MySqlColumnCompiler;
@@ -4,7 +4,6 @@ import { type Dictionary, type Type } from '@mikro-orm/core';
4
4
  import type { AbstractSqlConnection } from '../../AbstractSqlConnection';
5
5
  import { SchemaHelper } from '../../schema/SchemaHelper';
6
6
  import type { DatabaseSchema } from '../../schema/DatabaseSchema';
7
- import type { DatabaseTable } from '../../schema/DatabaseTable';
8
7
  export declare class MySqlSchemaHelper extends SchemaHelper {
9
8
  private readonly _cache;
10
9
  static readonly DEFAULT_VALUES: {
@@ -27,8 +26,6 @@ export declare class MySqlSchemaHelper extends SchemaHelper {
27
26
  getRenameColumnSQL(tableName: string, oldColumnName: string, to: Column): string;
28
27
  getRenameIndexSQL(tableName: string, index: IndexDef, oldIndexName: string): string;
29
28
  getChangeColumnCommentSQL(tableName: string, to: Column, schemaName?: string): string;
30
- createTableColumn(table: Knex.TableBuilder, column: Column, fromTable: DatabaseTable, changedProperties?: Set<string>): Knex.ColumnBuilder | undefined;
31
- configureColumn(column: Column, col: Knex.ColumnBuilder, knex: Knex, changedProperties?: Set<string>): Knex.ColumnBuilder;
32
29
  private getColumnDeclarationSQL;
33
30
  getForeignKeysSQL(tableName: string, schemaName?: string): string;
34
31
  getAllEnumDefinitions(connection: AbstractSqlConnection, tables: Table[]): Promise<Dictionary<Dictionary<string[]>>>;
@@ -208,18 +208,6 @@ class MySqlSchemaHelper extends SchemaHelper_1.SchemaHelper {
208
208
  const columnName = this.platform.quoteIdentifier(to.name);
209
209
  return `alter table ${tableName} modify ${columnName} ${this.getColumnDeclarationSQL(to)}`;
210
210
  }
211
- createTableColumn(table, column, fromTable, changedProperties) {
212
- if (column.mappedType instanceof core_1.MediumIntType) {
213
- return table.specificType(column.name, this.getColumnDeclarationSQL(column, true));
214
- }
215
- return super.createTableColumn(table, column, fromTable, changedProperties);
216
- }
217
- configureColumn(column, col, knex, changedProperties) {
218
- if (column.mappedType instanceof core_1.MediumIntType) {
219
- return col;
220
- }
221
- return super.configureColumn(column, col, knex, changedProperties);
222
- }
223
211
  getColumnDeclarationSQL(col, addPrimary = false) {
224
212
  let ret = col.type;
225
213
  ret += col.unsigned ? ' unsigned' : '';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/knex",
3
- "version": "6.3.11-dev.17",
3
+ "version": "6.3.11-dev.19",
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,7 +66,7 @@
66
66
  "@mikro-orm/core": "^6.3.10"
67
67
  },
68
68
  "peerDependencies": {
69
- "@mikro-orm/core": "6.3.11-dev.17",
69
+ "@mikro-orm/core": "6.3.11-dev.19",
70
70
  "better-sqlite3": "*",
71
71
  "libsql": "*",
72
72
  "mariadb": "*"
@@ -129,9 +129,9 @@ class SchemaHelper {
129
129
  if (column.autoincrement && !column.generated && !compositePK && (!changedProperties || changedProperties.has('autoincrement') || changedProperties.has('type'))) {
130
130
  const primaryKey = !changedProperties && !this.hasNonDefaultPrimaryKeyName(fromTable);
131
131
  if (column.mappedType instanceof core_1.BigIntType) {
132
- return table.bigIncrements(column.name, { primaryKey, unsigned: column.unsigned });
132
+ return table.bigIncrements(column.name, { primaryKey, unsigned: column.unsigned, type: column.type });
133
133
  }
134
- return table.increments(column.name, { primaryKey, unsigned: column.unsigned });
134
+ return table.increments(column.name, { primaryKey, unsigned: column.unsigned, type: column.type });
135
135
  }
136
136
  if (column.mappedType instanceof core_1.EnumType && column.enumItems?.every(item => core_1.Utils.isString(item))) {
137
137
  return table.enum(column.name, column.enumItems);
package/typings.d.ts CHANGED
@@ -185,14 +185,13 @@ export interface ICriteriaNode<T extends object> {
185
185
  getPath(addIndex?: boolean): string;
186
186
  getPivotPath(path: string): string;
187
187
  }
188
+ export type IncrementOptions = {
189
+ primaryKey?: boolean;
190
+ unsigned?: boolean;
191
+ type?: Column['type'];
192
+ };
188
193
  export interface ExpandedTableBuilder extends Knex.TableBuilder {
189
- increments(columnName?: string, options?: {
190
- primaryKey?: boolean;
191
- unsigned?: boolean;
192
- }): Knex.ColumnBuilder;
193
- bigIncrements(columnName?: string, options?: {
194
- primaryKey?: boolean;
195
- unsigned?: boolean;
196
- }): Knex.ColumnBuilder;
194
+ increments(columnName?: string, options?: IncrementOptions): Knex.ColumnBuilder;
195
+ bigIncrements(columnName?: string, options?: IncrementOptions): Knex.ColumnBuilder;
197
196
  }
198
197
  export {};