Setting text column type in MySQL is case sensitive
Author: zakiniCreated Jan 24, 2019Updated Jul 19, 2026
LabelsNG_bugNG_difficulty_easy
Environment
Knex version: 0.16.3 Database + version: MySQL 5.7.21 OS: macOS 10.13.6
Bug
Setting the type of a MySQL TEXT column only works if the type is lower case. MySQL is case insensitive for this kind of thing, so I'd expect knex to do the same.
const knex = require('knex')({ client: 'mysql' });
const statement1 = knex.schema.createTable('foo1', (table) => {
table.text('bar', 'MEDIUMTEXT');
});
console.log(statement1.toSQL());
// [ { sql: 'create table `foo1` (`bar` text)', bindings: [] } ]
const statement2 = knex.schema.createTable('foo2', (table) => {
table.text('bar', 'mediumtext');
});
console.log(statement2.toSQL());
// [ { sql: 'create table `foo2` (`bar` mediumtext)', bindings: [] } ]Source: knex/knex