Skip to content

renameColumn not working?#65

Merged
brianc merged 5 commits into
masterfrom
hotfix/rename-table
May 15, 2013
Merged

renameColumn not working?#65
brianc merged 5 commits into
masterfrom
hotfix/rename-table

Conversation

@brianc
Copy link
Copy Markdown
Owner

@brianc brianc commented May 14, 2013

I wonder if I'm doing something wrong or if it is just not working:

QueryGenerator.prototype.renameColumnQuery = function(tableName, attrNameBefore, attributes) {
    var attrNameAfter = Object.keys(attributes)[0]
      , columns       = [
                          { name: attrNameBefore, dataType: attributes[attrNameAfter] },
                          { name: attrNameAfter,  dataType: attributes[attrNameAfter] }
                        ]
      , model         = this.sql.define({ name: tableName, columns: columns })
      , scope         = model.alter().renameColumn(model.get(attrNameBefore), model.get(attrNameAfter))

    return this.evaluate(scope.toQuery())
  }

The columns are containing the following array:

[ { name: 'signature',
    dataType: 'VARCHAR(255) NOT NULL DEFAULT \'Signature\'' },
  { name: 'sig',
    dataType: 'VARCHAR(255) NOT NULL DEFAULT \'Signature\'' } ]

According to the tests, I'd expected that it would just work. But for some reason, node-sql is complaining about a missing dataType :(

@brianc
Copy link
Copy Markdown
Owner

brianc commented May 13, 2013

I'm not sure...do you have a test to reproduce this issue?

@sdepold
Copy link
Copy Markdown
Collaborator Author

sdepold commented May 13, 2013

@brianc
Copy link
Copy Markdown
Owner

brianc commented May 13, 2013

sweet - will fix

@sdepold
Copy link
Copy Markdown
Collaborator Author

sdepold commented May 13, 2013

just tried to debug it but i cannot find the right line. it seems that the datatype somewhere gets missing

@brianc
Copy link
Copy Markdown
Owner

brianc commented May 14, 2013

I fixed the issue on that branch

brianc added a commit that referenced this pull request May 15, 2013
@brianc brianc merged commit b4d257f into master May 15, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants