Fixes Maria issue with 'NULL' returned instead of NULL on MariaDB 10.2.6+ (#5181)

This commit is contained in:
Connor Tumbleson 2022-05-22 08:39:45 -04:00 committed by GitHub
parent bf4318f0ec
commit b20047bba5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 1 deletions

View File

@ -131,7 +131,7 @@ class QueryCompiler_MySQL extends QueryCompiler {
output(resp) {
const out = resp.reduce(function (columns, val) {
columns[val.COLUMN_NAME] = {
defaultValue: val.COLUMN_DEFAULT,
defaultValue: val.COLUMN_DEFAULT === 'NULL' ? null : val.COLUMN_DEFAULT,
type: val.DATA_TYPE,
maxLength: val.CHARACTER_MAXIMUM_LENGTH,
nullable: val.IS_NULLABLE === 'YES',

View File

@ -423,6 +423,27 @@ describe('Additional', function () {
expect(expectedUuid).to.equal(originalUuid);
});
it ('#5154 - should properly mark COLUMN_DEFAULT as null', async function () {
if (!isMysql(knex)) {
return this.skip();
}
await knex.schema.dropTableIfExists('null_col');
await knex.schema.createTable('null_col', function (table) {
table.date('foo').defaultTo(null).nullable();
})
const columnInfo = await knex('null_col').columnInfo();
expect(columnInfo).to.deep.equal({
foo: {
type: 'date',
maxLength: null,
nullable: true,
defaultValue: null,
},
});
});
it('#2184 - should properly escape table name for SQLite columnInfo', async function () {
if (!isSQLite(knex)) {
return this.skip();