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

Commit 4e3b8abf by Josh Rickert Committed by Sushant

Port #6204 to v4 (fix #6203) (#6421)

1 parent e6d6f393
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
- [FIXED] Generate correct SQL for JSON attributes with quote. - [FIXED] Generate correct SQL for JSON attributes with quote.
[#6406](https://github.com/sequelize/sequelize/issues/6406) [#6406](https://github.com/sequelize/sequelize/issues/6406)
- [FIXED] Nested query return correct result when quoteIdentifiers is false. (Postgres) [#6363](https://github.com/sequelize/sequelize/issues/6363) - [FIXED] Nested query return correct result when quoteIdentifiers is false. (Postgres) [#6363](https://github.com/sequelize/sequelize/issues/6363)
- [FIXED] Fixed an issue where changing multiple ENUM columns in PostgreSQL could break. [#6203] (https://github.com/sequelize/sequelize/issues/6203)
## BC breaks: ## BC breaks:
- Range type bounds now default to [postgres default](https://www.postgresql.org/docs/9.5/static/rangetypes.html#RANGETYPES-CONSTRUCT) `[)` (inclusive, exclusive), previously was `()` (exclusive, exclusive) - Range type bounds now default to [postgres default](https://www.postgresql.org/docs/9.5/static/rangetypes.html#RANGETYPES-CONSTRUCT) `[)` (inclusive, exclusive), previously was `()` (exclusive, exclusive)
......
...@@ -216,7 +216,7 @@ const QueryGenerator = { ...@@ -216,7 +216,7 @@ const QueryGenerator = {
} }
if (attributes[attributeName].match(/^ENUM\(/)) { if (attributes[attributeName].match(/^ENUM\(/)) {
query = this.pgEnum(tableName, attributeName, attributes[attributeName]) + query; attrSql += this.pgEnum(tableName, attributeName, attributes[attributeName]);
definition = definition.replace(/^ENUM\(.+\)/, this.quoteIdentifier('enum_' + tableName + '_' + attributeName)); definition = definition.replace(/^ENUM\(.+\)/, this.quoteIdentifier('enum_' + tableName + '_' + attributeName));
definition += ' USING (' + this.quoteIdentifier(attributeName) + '::' + this.quoteIdentifier(definition) + ')'; definition += ' USING (' + this.quoteIdentifier(attributeName) + '::' + this.quoteIdentifier(definition) + ')';
} }
......
...@@ -201,6 +201,16 @@ if (dialect.match(/^postgres/)) { ...@@ -201,6 +201,16 @@ if (dialect.match(/^postgres/)) {
} }
], ],
changeColumnQuery: [
{
arguments: ['myTable', {
col_1: "ENUM('value 1', 'value 2') NOT NULL",
col_2: "ENUM('value 3', 'value 4') NOT NULL"
}],
expectation: 'ALTER TABLE "myTable" ALTER COLUMN "col_1" SET NOT NULL;ALTER TABLE "myTable" ALTER COLUMN "col_1" DROP DEFAULT;CREATE TYPE "public"."enum_myTable_col_1" AS ENUM(\'value 1\', \'value 2\');ALTER TABLE "myTable" ALTER COLUMN "col_1" TYPE "public"."enum_myTable_col_1" USING ("col_1"::"public.enum_myTable_col_1");ALTER TABLE "myTable" ALTER COLUMN "col_2" SET NOT NULL;ALTER TABLE "myTable" ALTER COLUMN "col_2" DROP DEFAULT;CREATE TYPE "public"."enum_myTable_col_2" AS ENUM(\'value 3\', \'value 4\');ALTER TABLE "myTable" ALTER COLUMN "col_2" TYPE "public"."enum_myTable_col_2" USING ("col_2"::"public.enum_myTable_col_2");'
}
],
selectQuery: [ selectQuery: [
{ {
arguments: ['myTable'], arguments: ['myTable'],
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!