File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -60,13 +60,13 @@ Table.prototype.hasColumn = function(col) {
6060Table . prototype . getColumn =
6161Table . prototype . get =
6262function ( colName ) {
63- var col = this . createColumn ( colName ) ;
64-
65- if ( ! this . hasColumn ( col ) ) {
66- throw new Error ( 'Table ' + this . _name + ' does not have a column named ' + colName ) ;
63+ for ( var i = 0 ; i < this . columns . length ; i ++ ) {
64+ var col = this . columns [ i ] ;
65+ if ( col . name == colName ) {
66+ return col ;
67+ }
6768 }
68-
69- return col ;
69+ throw new Error ( 'Table ' + this . _name + ' does not have a column named ' + colName ) ;
7070} ;
7171
7272Table . prototype . getSchema = function ( ) {
Original file line number Diff line number Diff line change @@ -121,3 +121,21 @@ Harness.test({
121121 mysql : 'ALTER TABLE `group` CHANGE COLUMN `userId` `id` varchar(100)' ,
122122 params : [ ]
123123} ) ;
124+
125+ var UserWithSignature = Table . define ( {
126+ name : 'UserWithSignature' ,
127+ columns : [ {
128+ name : 'Signature' ,
129+ dataType : "VARCHAR(255) NOT NULL DEFAULT 'Signature'"
130+ } ]
131+ } )
132+
133+ Harness . test ( {
134+ query : UserWithSignature . alter ( ) . renameColumn ( UserWithSignature . get ( 'Signature' ) , 'sig' ) ,
135+ pg : 'ALTER TABLE "UserWithSignature" RENAME COLUMN "Signature" TO "sig"' ,
136+ mysql : 'ALTER TABLE `UserWithSignature` CHANGE COLUMN `Signature` `sig` VARCHAR(255) NOT NULL DEFAULT \'Signature\'' ,
137+ sqlite : {
138+ text : 'Sqlite cannot rename columns' ,
139+ throws : true
140+ }
141+ } )
You can’t perform that action at this time.
0 commit comments