File tree 2 files changed +45
-2
lines changed
2 files changed +45
-2
lines changed Original file line number Diff line number Diff line change @@ -176,7 +176,7 @@ function mixinMigration(MySQL, mysql) {
176
176
} ) ;
177
177
}
178
178
if ( found ) {
179
- actualize ( colName , found ) ;
179
+ actualize ( propName , found ) ;
180
180
} else {
181
181
sql . push ( 'ADD COLUMN ' + self . client . escapeId ( colName ) + ' ' +
182
182
self . buildColumnDefinition ( model , propName ) ) ;
@@ -186,7 +186,7 @@ function mixinMigration(MySQL, mysql) {
186
186
function actualize ( propName , oldSettings ) {
187
187
var newSettings = m . properties [ propName ] ;
188
188
if ( newSettings && changed ( newSettings , oldSettings ) ) {
189
- var pName = self . client . escapeId ( propName ) ;
189
+ var pName = self . columnEscaped ( model , propName ) ;
190
190
sql . push ( 'CHANGE COLUMN ' + pName + ' ' + pName + ' ' +
191
191
self . buildColumnDefinition ( model , propName ) ) ;
192
192
}
Original file line number Diff line number Diff line change @@ -529,6 +529,49 @@ describe('MySQL connector', function() {
529
529
verifyMysqlColumnNameAutoupdate ( done ) ;
530
530
} ) ;
531
531
532
+ it ( 'should update the nullable property of "first_name" to false' , function ( done ) {
533
+ // update the model "required" property
534
+ var schema = {
535
+ name : 'ColRenameTest' ,
536
+ options : {
537
+ idInjection : false ,
538
+ mysql : {
539
+ schema : 'myapp_test' ,
540
+ table : 'col_rename_test' ,
541
+ } ,
542
+ } ,
543
+ properties : {
544
+ firstName : {
545
+ type : 'String' ,
546
+ required : true ,
547
+ length : 40 ,
548
+ mysql : {
549
+ columnName : 'first_name' ,
550
+ dataType : 'varchar' ,
551
+ dataLength : 40 ,
552
+ } ,
553
+ } ,
554
+ lastName : {
555
+ type : 'String' ,
556
+ required : false ,
557
+ length : 40 ,
558
+ } ,
559
+ } ,
560
+ } ;
561
+
562
+ ds . createModel ( schema . name , schema . properties , schema . options ) ;
563
+
564
+ // nullable should be updated to false
565
+ ds . autoupdate ( 'ColRenameTest' , function ( err ) {
566
+ assert . ifError ( err ) ;
567
+ ds . discoverModelProperties ( 'col_rename_test' , function ( err , props ) {
568
+ assert . equal ( props [ 0 ] . nullable , 'N' ) ;
569
+ assert . equal ( props [ 0 ] . columnName , 'first_name' ) ;
570
+ done ( ) ;
571
+ } ) ;
572
+ } ) ;
573
+ } ) ;
574
+
532
575
function verifyMysqlColumnNameAutoupdate ( done ) {
533
576
ds . autoupdate ( 'ColRenameTest' , function ( err ) {
534
577
ds . discoverModelProperties ( 'col_rename_test' , function ( err , props ) {
You can’t perform that action at this time.
0 commit comments