@mikro-orm/knex 6.3.11-dev.14 → 6.3.11-dev.15

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.
@@ -2,8 +2,10 @@ import BaseMySqlColumnCompiler from 'knex/lib/dialects/mysql/schema/mysql-column
2
2
  export declare class MySqlColumnCompiler extends BaseMySqlColumnCompiler {
3
3
  increments(this: any, options?: {
4
4
  primaryKey: boolean;
5
+ unsigned: boolean;
5
6
  }): string;
6
7
  bigincrements(this: any, options?: {
7
8
  primaryKey: boolean;
9
+ unsigned: boolean;
8
10
  }): string;
9
11
  }
@@ -8,12 +8,14 @@ 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 }) {
12
- return 'int unsigned not null auto_increment' + (this.tableCompiler._canBeAddPrimaryKey(options) ? ' primary key' : '');
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' : '');
13
14
  }
14
15
  /* istanbul ignore next */
15
- bigincrements(options = { primaryKey: true }) {
16
- return 'bigint unsigned not null auto_increment' + (this.tableCompiler._canBeAddPrimaryKey(options) ? ' primary key' : '');
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' : '');
17
19
  }
18
20
  }
19
21
  exports.MySqlColumnCompiler = MySqlColumnCompiler;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/knex",
3
- "version": "6.3.11-dev.14",
3
+ "version": "6.3.11-dev.15",
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.14",
69
+ "@mikro-orm/core": "6.3.11-dev.15",
70
70
  "better-sqlite3": "*",
71
71
  "libsql": "*",
72
72
  "mariadb": "*"
@@ -96,7 +96,7 @@ class DatabaseTable {
96
96
  extra: prop.extra,
97
97
  ignoreSchemaChanges: prop.ignoreSchemaChanges,
98
98
  };
99
- this.columns[field].unsigned ||= this.columns[field].autoincrement;
99
+ this.columns[field].unsigned ??= this.columns[field].autoincrement;
100
100
  const defaultValue = this.platform.getSchemaHelper().normalizeDefaultValue(prop.defaultRaw, prop.length);
101
101
  this.columns[field].default = defaultValue;
102
102
  });
@@ -2,7 +2,7 @@ import { type Connection, type Dictionary } from '@mikro-orm/core';
2
2
  import type { Knex } from 'knex';
3
3
  import type { AbstractSqlConnection } from '../AbstractSqlConnection';
4
4
  import type { AbstractSqlPlatform } from '../AbstractSqlPlatform';
5
- import type { CheckDef, Column, ForeignKey, IndexDef, Table, TableDifference } from '../typings';
5
+ import type { CheckDef, Column, ExpandedTableBuilder, ForeignKey, IndexDef, Table, TableDifference } from '../typings';
6
6
  import type { DatabaseSchema } from './DatabaseSchema';
7
7
  import type { DatabaseTable } from './DatabaseTable';
8
8
  export declare abstract class SchemaHelper {
@@ -30,7 +30,7 @@ export declare abstract class SchemaHelper {
30
30
  getRenameIndexSQL(tableName: string, index: IndexDef, oldIndexName: string): string;
31
31
  getDropColumnsSQL(tableName: string, columns: Column[], schemaName?: string): string;
32
32
  hasNonDefaultPrimaryKeyName(table: DatabaseTable): boolean;
33
- createTableColumn(table: Knex.TableBuilder, column: Column, fromTable: DatabaseTable, changedProperties?: Set<string>, alter?: boolean): Knex.ColumnBuilder | undefined;
33
+ createTableColumn(table: ExpandedTableBuilder, column: Column, fromTable: DatabaseTable, changedProperties?: Set<string>, alter?: boolean): Knex.ColumnBuilder | undefined;
34
34
  configureColumn(column: Column, col: Knex.ColumnBuilder, knex: Knex, changedProperties?: Set<string>): Knex.ColumnBuilder;
35
35
  configureColumnDefault(column: Column, col: Knex.ColumnBuilder, knex: Knex, changedProperties?: Set<string>): Knex.ColumnBuilder;
36
36
  getPreAlterTable(tableDiff: TableDifference, safe: boolean): string;
@@ -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 });
132
+ return table.bigIncrements(column.name, { primaryKey, unsigned: column.unsigned });
133
133
  }
134
- return table.increments(column.name, { primaryKey });
134
+ return table.increments(column.name, { primaryKey, unsigned: column.unsigned });
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,4 +185,14 @@ export interface ICriteriaNode<T extends object> {
185
185
  getPath(addIndex?: boolean): string;
186
186
  getPivotPath(path: string): string;
187
187
  }
188
+ 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;
197
+ }
188
198
  export {};