Skip to content

Commit 728b240

Browse files
committed
Remove dialect canAliasPK check for generating fieldnames. (#571)
This was a workaround to a sequelize bug that has been fixed.
1 parent ff2893d commit 728b240

File tree

6 files changed

+2
-11
lines changed

6 files changed

+2
-11
lines changed

src/auto-generator.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -426,11 +426,7 @@ export class AutoGenerator {
426426
}
427427

428428
if (field !== fieldName) {
429-
// write the original fieldname, unless it is a key and the column names are case-insensitive
430-
// because Sequelize may request the same column twice in a join condition otherwise.
431-
if (!fieldObj.primaryKey || this.dialect.canAliasPK || field.toUpperCase() !== fieldName.toUpperCase()) {
432-
str += space[3] + "field: '" + field + "',\n";
433-
}
429+
str += space[3] + "field: '" + field + "',\n";
434430
}
435431

436432
// removes the last `,` within the attribute options

src/dialects/dialect-options.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import { Utils } from "sequelize";
44
export interface DialectOptions {
55
name: string;
66
hasSchema: boolean;
7-
/** whether to write the db field name for primaryKey fields ('id'). Can cause errors in some dialects because field name is included twice in queries. */
8-
canAliasPK: boolean;
7+
98
getForeignKeysQuery: (tableName: string, schemaName: string) => string;
109
remapForeignKeysRow?: (tableName: string, row: FKRow) => FKRelation;
1110
countTriggerQuery: (tableName: string, schemaName: string) => string;

src/dialects/mssql.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { addTicks, DialectOptions, FKRow, makeCondition } from "./dialect-option
44
export const mssqlOptions: DialectOptions = {
55
name: 'mssql',
66
hasSchema: true,
7-
canAliasPK: false,
87
/**
98
* Generates an SQL query that returns all foreign keys of a table.
109
*

src/dialects/mysql.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { addTicks, DialectOptions, FKRow, makeCondition } from "./dialect-option
44
export const mysqlOptions: DialectOptions = {
55
name: 'mysql',
66
hasSchema: false,
7-
canAliasPK: false,
87
/**
98
* Generates an SQL query that returns all foreign keys of a table.
109
*

src/dialects/postgres.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { addTicks, DialectOptions, FKRow, makeCondition } from "./dialect-option
44
export const postgresOptions: DialectOptions = {
55
name: 'postgres',
66
hasSchema: true,
7-
canAliasPK: true,
87
/**
98
* Generates an SQL query that returns all foreign keys of a table.
109
*

src/dialects/sqlite.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { addTicks, DialectOptions, FKRow } from "./dialect-options";
44
export const sqliteOptions: DialectOptions = {
55
name: 'sqlite',
66
hasSchema: false,
7-
canAliasPK: true,
87
/**
98
* Generates an SQL query that returns all foreign keys of a table.
109
*

0 commit comments

Comments
 (0)