Custom types on arrays in posgres generates the wrong name when using underscores in columns #13204
Closed
2 of 7 tasks
Labels
dialect: postgres
For issues and PRs. Things that involve PostgreSQL (and do not involve all dialects).
Great SSCCE
This issue has a great SSCCE/MCVE/reprex posted and therefore deserves extra attention! :)
status: understood
For issues. Applied when the issue is understood / reproducible.
type: bug
Issue Description
When using underscored column names in pg enum array types, bulkUpdate queries fails (Actually this will happen for any field uses the "field" property to rename the column, as the data-type file in the postgres dialect is not using the correct "overwritten" propery)
What are you doing?
Here is the link to the SSCCE for this issue: sequelize/sequelize-sscce#158
What do you expect to happen?
I want that when using a model with underscored columns 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:
when executing the bulkCreate I'm expecting that the data is inserted, but instead fails
the error output is clear
enum_book_details_originalCategories
is not the proper type in the database, it should beenum_book_details_original_categories
respecting the underscoring.Additional context
Environment
Issue Template Checklist
How does this problem relate to dialects?
Would you be willing to resolve this issue by submitting a Pull Request?
Dev notes
I locally patched my code with a simple sed command:
sed -i 's/options\.field\.fieldName/options\.field\.field/g' ./node_modules/sequelize/lib/dialects/postgres/data-types.js
And from what I followed in the code is just a change on line 483 at
lib/dialects/postgres/data-types.js
instead ofUtils.generateEnumName(options.field.Model.getTableName(), options.field.fieldName),
the code should readUtils.generateEnumName(options.field.Model.getTableName(), options.field.field),
(I debuged it to confirm and the sed patch works locally).So the change is realively easy, my only concern is extra testing that may be needed.
The text was updated successfully, but these errors were encountered: