Skip to content

Commit

Permalink
Fixes Maria issue with 'NULL' returned instead of NULL on MariaDB 10.…
Browse files Browse the repository at this point in the history
…2.6+ (#5181)
  • Loading branch information
iBotPeaches committed May 22, 2022
1 parent bf4318f commit b20047b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/dialects/mysql/query/mysql-querycompiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
21 changes: 21 additions & 0 deletions test/integration2/query/misc/additional.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit b20047b

Please sign in to comment.