Issue Creation Checklist
Bug Description
For postgres array of enum types.
When sequelize generates the enum name for bulk create queries for an ARRAY datat type is not considering that enums can be inside a schema, and tries to use the full name of the object (schema).(table) and adds enum_ at the begining.
This is not the logic used for creating the initial value of the enum and the final enum name is invalid. If there is a schema present it should only add enum_ to the table name and use the schema for reference at the begining of the type.
SSCCE
Here is the link to the SSCCE for this issue: sequelize/sequelize-sscce#204
What do you expect to happen?
I want that when using a model with a property that is an array of enums on the table in a postgres database, custom types in array are casted to the proper type when doing queries (in particular bulkCreate).
What is actually happening?
For a simple model like: (look that the schema is not the default and is redefined to: 'test')
BookDetails.init({
uniqueName: {
type: Sequelize.DataTypes.STRING(100),
unique: true,
allowNull: false,
primaryKey: true
},
originalCategories: {
type: Sequelize.DataTypes.ARRAY(Sequelize.DataTypes.ENUM({
values: ['drama', 'comedy'],
})),
},
}, {
underscored: true,
modelName: 'BookDetails',
schema: 'test',
sequelize
});
when executing the bulkCreate I'm expecting that the data is inserted, but instead fails
await BookDetails.bulkCreate([{
uniqueName: 'test',
originalCategories: ['drama']
}]);
the error output is clear:
INSERT INTO "test"."book_details" ("unique_name","original_categories") VALUES ('test',ARRAY['drama']::"enum_test.book_details_original_categories"[]) RETURNING "unique_name","original_categories";`,
parameters: undefined
},
original: error: type "enum_test.book_details_original_categories[]" does not exist
enum_test.book_details_original_categories is not the proper type in the database, it should be test.enum_book_details_original_categories respecting the underscoring.
enum_test.book_details_original_categories is not the proper type in the database, it should be test.enum_book_details_original_categories respecting the schema name.
Additional context
Environment
- Sequelize version: 6.12.1
- Node.js version: 14.18.2
- Operating System: Ubuntu 20.04
Bug Report Checklist
How does this problem relate to dialects?
Would you be willing to resolve this issue by submitting a Pull Request?
Issue Creation Checklist
Bug Description
For postgres array of enum types.
When sequelize generates the enum name for bulk create queries for an ARRAY datat type is not considering that enums can be inside a schema, and tries to use the full name of the object (schema).(table) and adds enum_ at the begining.
This is not the logic used for creating the initial value of the enum and the final enum name is invalid. If there is a schema present it should only add enum_ to the table name and use the schema for reference at the begining of the type.
SSCCE
Here is the link to the SSCCE for this issue: sequelize/sequelize-sscce#204
What do you expect to happen?
I want that when using a model with a property that is an array of enums on the table in a postgres database, custom types in array are casted to the proper type when doing queries (in particular bulkCreate).
What is actually happening?
For a simple model like: (look that the schema is not the default and is redefined to: 'test')
when executing the bulkCreate I'm expecting that the data is inserted, but instead fails
the error output is clear:
enum_test.book_details_original_categoriesis not the proper type in the database, it should betest.enum_book_details_original_categoriesrespecting the schema name.Additional context
Environment
Bug Report Checklist
How does this problem relate to dialects?
Would you be willing to resolve this issue by submitting a Pull Request?