Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sqlite): quote table names in sqlite getForeignKeysQuery #12752

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/dialects/sqlite/query-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ class SQLiteQueryGenerator extends MySqlQueryGenerator {
* @private
*/
getForeignKeysQuery(tableName) {
return `PRAGMA foreign_key_list(${tableName})`;
return `PRAGMA foreign_key_list(${this.quoteTable(this.addSchema(tableName))})`;
}
}

Expand Down
7 changes: 7 additions & 0 deletions test/unit/dialects/sqlite/query-generator.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,13 @@ if (dialect === 'sqlite') {
'INSERT INTO `myTable` SELECT `commit`, `bar` FROM `myTable_backup`;' +
'DROP TABLE `myTable_backup`;'
}
],
getForeignKeysQuery: [
{
title: 'Properly quotes table names',
arguments: ['myTable'],
expectation: 'PRAGMA foreign_key_list(`myTable`)'
}
]
};

Expand Down