mirror of
https://github.com/knex/knex.git
synced 2026-01-04 02:57:58 +00:00
MSSQL columnInfo() had hard coded schema name (#1585)
* MSSQL columnInfo() had hard coded schema name * Change let to const for columnInfo bindings array
This commit is contained in:
parent
54563dc8e0
commit
f969d5236a
@ -158,11 +158,19 @@ assign(QueryCompiler_MSSQL.prototype, {
|
||||
// Compiles a `columnInfo` query.
|
||||
columnInfo() {
|
||||
const column = this.single.columnInfo;
|
||||
const sql =
|
||||
`select * from information_schema.columns where table_name = ? and table_schema = 'dbo'`;
|
||||
let sql =`select * from information_schema.columns where table_name = ? and table_catalog = ?`;
|
||||
const bindings = [this.single.table, this.client.database()];
|
||||
|
||||
if (this.single.schema) {
|
||||
sql += ' and table_schema = ?';
|
||||
bindings.push(this.single.schema);
|
||||
} else {
|
||||
sql += ` and table_schema = 'dbo'`;
|
||||
}
|
||||
|
||||
return {
|
||||
sql,
|
||||
bindings: [this.single.table],
|
||||
bindings: bindings,
|
||||
output(resp) {
|
||||
const out = resp.reduce(function(columns, val) {
|
||||
columns[val.COLUMN_NAME] = {
|
||||
|
||||
@ -121,8 +121,8 @@ module.exports = function(knex) {
|
||||
}
|
||||
);
|
||||
tester('mssql',
|
||||
'select * from information_schema.columns where table_name = ? and table_schema = \'dbo\'',
|
||||
['datatype_test'], {
|
||||
'select * from information_schema.columns where table_name = ? and table_catalog = ? and table_schema = \'dbo\'',
|
||||
['datatype_test', 'knex_test'], {
|
||||
"enum_value": {
|
||||
"defaultValue": null,
|
||||
"maxLength": 100,
|
||||
@ -173,7 +173,7 @@ module.exports = function(knex) {
|
||||
}
|
||||
);
|
||||
tester('mssql',
|
||||
'select * from information_schema.columns where table_name = ? and table_schema = \'dbo\'',
|
||||
'select * from information_schema.columns where table_name = ? and table_catalog = ? and table_schema = \'dbo\'',
|
||||
null, {
|
||||
"defaultValue": null,
|
||||
"maxLength": null,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user