mirror of
https://github.com/knex/knex.git
synced 2025-07-03 15:10:07 +00:00
Fixes Maria issue with 'NULL' returned instead of NULL on MariaDB 10.2.6+ (#5181)
This commit is contained in:
parent
bf4318f0ec
commit
b20047bba5
@ -131,7 +131,7 @@ class QueryCompiler_MySQL extends QueryCompiler {
|
|||||||
output(resp) {
|
output(resp) {
|
||||||
const out = resp.reduce(function (columns, val) {
|
const out = resp.reduce(function (columns, val) {
|
||||||
columns[val.COLUMN_NAME] = {
|
columns[val.COLUMN_NAME] = {
|
||||||
defaultValue: val.COLUMN_DEFAULT,
|
defaultValue: val.COLUMN_DEFAULT === 'NULL' ? null : val.COLUMN_DEFAULT,
|
||||||
type: val.DATA_TYPE,
|
type: val.DATA_TYPE,
|
||||||
maxLength: val.CHARACTER_MAXIMUM_LENGTH,
|
maxLength: val.CHARACTER_MAXIMUM_LENGTH,
|
||||||
nullable: val.IS_NULLABLE === 'YES',
|
nullable: val.IS_NULLABLE === 'YES',
|
||||||
|
@ -423,6 +423,27 @@ describe('Additional', function () {
|
|||||||
expect(expectedUuid).to.equal(originalUuid);
|
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 () {
|
it('#2184 - should properly escape table name for SQLite columnInfo', async function () {
|
||||||
if (!isSQLite(knex)) {
|
if (!isSQLite(knex)) {
|
||||||
return this.skip();
|
return this.skip();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user