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

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

Merged
merged 2 commits into from
May 22, 2022
Merged
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 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