不要怂,就是干,撸起袖子干!

Commit 03155ad5 by Sushant Committed by GitHub

fix(postgres): enum with string COMMENT breaks query (#9891)

1 parent 78eb82e1
...@@ -99,7 +99,7 @@ class MSSQLQueryGenerator extends AbstractQueryGenerator { ...@@ -99,7 +99,7 @@ class MSSQLQueryGenerator extends AbstractQueryGenerator {
let dataType = attributes[attr]; let dataType = attributes[attr];
let match; let match;
if (_.includes(dataType, 'COMMENT')) { if (_.includes(dataType, 'COMMENT ')) {
const commentMatch = dataType.match(/^(.+) (COMMENT.*)$/); const commentMatch = dataType.match(/^(.+) (COMMENT.*)$/);
const commentText = commentMatch[2].replace(/COMMENT/, '').trim(); const commentText = commentMatch[2].replace(/COMMENT/, '').trim();
commentStr += _.template(commentTemplate, this._templateSettings)({ commentStr += _.template(commentTemplate, this._templateSettings)({
......
...@@ -49,7 +49,7 @@ class PostgresQueryGenerator extends AbstractQueryGenerator { ...@@ -49,7 +49,7 @@ class PostgresQueryGenerator extends AbstractQueryGenerator {
for (const attr in attributes) { for (const attr in attributes) {
const quotedAttr = this.quoteIdentifier(attr); const quotedAttr = this.quoteIdentifier(attr);
const i = attributes[attr].indexOf('COMMENT'); const i = attributes[attr].indexOf('COMMENT ');
if (i !== -1) { if (i !== -1) {
// Move comment to a separate query // Move comment to a separate query
const escapedCommentText = this.escape(attributes[attr].substring(i + 8)); const escapedCommentText = this.escape(attributes[attr].substring(i + 8));
......
...@@ -71,6 +71,15 @@ describe(Support.getTestDialectTeaser('QueryInterface'), () => { ...@@ -71,6 +71,15 @@ describe(Support.getTestDialectTeaser('QueryInterface'), () => {
}); });
}); });
it('should work with enums (5)', function () {
return this.queryInterface.createTable('SomeTable', {
someEnum: {
type: DataTypes.ENUM(['COMMENT']),
comment: 'special enum col'
}
});
});
it('should work with schemas', function () { it('should work with schemas', function () {
const self = this; const self = this;
return self.sequelize.createSchema('hero').then(() => { return self.sequelize.createSchema('hero').then(() => {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!