Skip to content

Commit

Permalink
Escape column names in PRIMARY KEY constraint
Browse files Browse the repository at this point in the history
When a column used as the primary key has a name which collides
with a reserved word the name must be escaped, otherwise the query
will cause a syntax error.
  • Loading branch information
rasapetter committed Apr 10, 2015
1 parent 59c0e6c commit 9b20faa
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/utils.js
Expand Up @@ -78,7 +78,7 @@ utils.buildSchema = function(obj) {
}));

var constraints = _.compact([
primaryKeys.length && 'PRIMARY KEY (' + primaryKeys.join(',') + ')'
primaryKeys.length && 'PRIMARY KEY ("' + primaryKeys.join('","') + '")'
]).join(', ');

return _.compact([ columns, constraints ]).join(', ');
Expand Down

0 comments on commit 9b20faa

Please sign in to comment.