Make sqlite3 hasColumn case insensitive (#3435)

This commit is contained in:
Alexandre BODIN 2019-11-14 19:31:59 +01:00 committed by Igor Savin
parent 115ff3c136
commit 0214f11663
2 changed files with 21 additions and 2 deletions

View File

@ -29,8 +29,8 @@ SchemaCompiler_SQLite3.prototype.hasColumn = function(tableName, column) {
output(resp) { output(resp) {
return some(resp, (col) => { return some(resp, (col) => {
return ( return (
this.client.wrapIdentifier(col.name) === this.client.wrapIdentifier(col.name.toLowerCase()) ===
this.client.wrapIdentifier(column) this.client.wrapIdentifier(column.toLowerCase())
); );
}); });
}, },

View File

@ -1048,6 +1048,25 @@ module.exports = function(knex) {
expect(exists).to.equal(true); expect(exists).to.equal(true);
}); });
}); });
describe('sqlite only', function() {
if (
!knex ||
!knex.client ||
!/sqlite3/i.test(knex.client.driverName)
) {
return Promise.resolve();
}
it('checks whether a column exists without being case sensitive, resolving with a boolean', async () => {
const exists = await knex.schema.hasColumn(
'accounts',
'FIRST_NAME'
);
expect(exists).to.equal(true);
});
});
}); });
describe('using processorss', function() { describe('using processorss', function() {