Fix the default length for strings to avoid row size overflow

This commit is contained in:
Raymond Feng 2014-07-08 11:23:45 -07:00
parent 3dbd77c094
commit abaabff01a
2 changed files with 4 additions and 4 deletions

View File

@ -1027,11 +1027,11 @@ function stringOptionsByType(p, dt) {
case 'varchar':
// The maximum length for an ID column is 1000 bytes
// The maximum row size is 64K
var len = p.limit || ((p.type !== String) ? 8192 : p.id ? 255: 1024);
var len = p.length || p.limit || ((p.type !== String) ? 4096 : p.id ? 255: 512);
dt += '(' + len + ')';
break;
case 'char':
len = p.limit || 255;
len = p.length || p.limit || 255;
dt += '(' + len + ')';
break;

View File

@ -26,14 +26,14 @@ describe('migrations', function () {
Extra: 'auto_increment' },
email: {
Field: 'email',
Type: 'varchar(1024)',
Type: 'varchar(512)',
Null: 'NO',
Key: 'MUL',
Default: null,
Extra: '' },
name: {
Field: 'name',
Type: 'varchar(1024)',
Type: 'varchar(512)',
Null: 'YES',
Key: '',
Default: null,