Skip to content

Commit 3862769

Browse files
committed
fix(builder): update NOT NULL condition to include primaryKey option and reorder comment handling
1 parent f4bf462 commit 3862769

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/builder.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ class ManageSQLBuilder extends Builder {
680680
} else if (type === 'TINYINT') {
681681
str += '(4)';
682682
}
683-
if (options.allowNull === false) {
683+
if (options.allowNull === false || options.primaryKey === true) {
684684
str += ' NOT NULL';
685685
}
686686
if (options.unsigned === true) {
@@ -705,12 +705,12 @@ class ManageSQLBuilder extends Builder {
705705
if (options.onUpdate) {
706706
str += ` ON UPDATE ${options.onUpdate}`;
707707
}
708-
if (is.string(options.comment) && is.empty(options.comment) === false) {
709-
str += ` COMMENT '${options.comment}'`;
710-
}
711708
if (options.autoIncrement === true) {
712709
str += ' AUTO_INCREMENT';
713710
}
711+
if (is.string(options.comment) && is.empty(options.comment) === false) {
712+
str += ` COMMENT '${options.comment}'`;
713+
}
714714
if (options.after) {
715715
str += ' AFTER `' + options.after + '`';
716716
}

0 commit comments

Comments
 (0)