Skip to content

Commit

Permalink
lib: Prevent unnecessary ALTER TABLE operation when the collation is …
Browse files Browse the repository at this point in the history
…unchanged
  • Loading branch information
nwoltman committed Sep 11, 2016
1 parent eca64f1 commit b5ae554
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 7 additions & 0 deletions lib/ColumnDefinitions/TextColumnDefinition.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ class TextColumnDefinition extends ColumnDefinition {
return false;
}

if (
this._collate && columnDefinition._collate &&
this._collate === columnDefinition._collate
) {
return true;
}

if (
this._charset !== columnDefinition._charset &&
(columnDefinition._charset || this._charset !== columnTableSchema.charset)
Expand Down
4 changes: 3 additions & 1 deletion test/integration/MySQLPlus.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ describe('MySQLPlus', function() {
b: Type.char(1).charset('utf8mb4'),
c: Type.char(1).charset('utf8mb4').collate('utf8mb4_unicode_ci'),
d: Type.char(1).collate('utf8mb4_unicode_ci'),
e: Type.char(1).collate('utf8mb4_bin'), // eslint-disable-line id-blacklist
},
charset: 'utf8mb4',
collate: 'utf8mb4_unicode_ci',
Expand All @@ -402,7 +403,8 @@ describe('MySQLPlus', function() {
' `a` char(1) COLLATE utf8mb4_unicode_ci DEFAULT NULL,\n' +
' `b` char(1) CHARACTER SET utf8mb4 DEFAULT NULL,\n' +
' `c` char(1) COLLATE utf8mb4_unicode_ci DEFAULT NULL,\n' +
' `d` char(1) COLLATE utf8mb4_unicode_ci DEFAULT NULL\n' +
' `d` char(1) COLLATE utf8mb4_unicode_ci DEFAULT NULL,\n' +
' `e` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL\n' +
') ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci';


Expand Down

0 comments on commit b5ae554

Please sign in to comment.