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

Commit 2172333c by warkenji Committed by Sushant

fix(postgre): escape enum values (#11402)

1 parent 1bd8ae1e
......@@ -791,7 +791,7 @@ class PostgresQueryGenerator extends AbstractQueryGenerator {
let values;
if (dataType.values) {
values = `ENUM('${dataType.values.join("', '")}')`;
values = `ENUM(${dataType.values.map(value => this.escape(value)).join(', ')})`;
} else {
values = dataType.toString().match(/^ENUM\(.+\)/)[0];
}
......
......@@ -266,6 +266,14 @@ if (dialect.match(/^postgres/)) {
});
describe('enums', () => {
it('should be able to create enums with escape values', function() {
const User = this.sequelize.define('UserEnums', {
mood: DataTypes.ENUM('happy', 'sad', '1970\'s')
});
return User.sync({ force: true });
});
it('should be able to ignore enum types that already exist', function() {
const User = this.sequelize.define('UserEnums', {
mood: DataTypes.ENUM('happy', 'sad', 'meh')
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!