You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am not sure is this problem with sequelize-typescript or sequelize, so please correct me.
Syntax error when trying to add enum column with comment that ends with bracket ")".
Other type (tested with DataType.TEXT) works as expected, without problems.
Versions
sequelize: 6.37.1
sequelize-typescript: 2.1.6
typescript: 5.3.3
pg: 8.11.3
Issue type
bug report
feature request
Actual behavior
For example (code in below section) sequelize creates this SQL (prettified):
DO
'BEGIN
CREATE TYPE "public"."enum_Model_status" AS ENUM(''active'', ''pending'', ''available'', ''inactive'', ''suspended'');
EXCEPTION WHEN duplicate_object THEN null;
END';
ALTER TABLE "public"."Model" ADD COLUMN "status" "public"."enum_Model_status"'; <--- Here is unnecessary single quote
And at the end you can see syntax error with unnecessary one single quote, between status" and ;
Error: unterminated quoted string at or near "';"
Expected behavior
Successfully creates column with comment with brackets
Steps to reproduce
Initialize sequelize, add one model
Using queryInterface add enum column with any comment that ends with symbol )
The issue is that the enum is passed there including the comment. It will now take the last closing bracket and replace the part in between with the enum name. It should stop before it encounters a comment.
It is also present in the v7-alphas, so it would be better to fix it there first and backport it to v6.
Issue
I am not sure is this problem with
sequelize-typescript
orsequelize
, so please correct me.Syntax error when trying to add enum column with comment that ends with bracket ")".
Other type (tested with
DataType.TEXT
) works as expected, without problems.Versions
Issue type
Actual behavior
For example (code in below section) sequelize creates this SQL (prettified):
And at the end you can see syntax error with unnecessary one single quote, between
status"
and;
Error:
unterminated quoted string at or near "';"
Expected behavior
Steps to reproduce
enum
column with any comment that ends with symbol)
Related code
Link to small reproducable repo: https://github.com/Mauzzz0/sequelize-comment-brackets-error
With two files:
case_fail.ts
,case_success.ts
Failed example:
Successfull example:
The text was updated successfully, but these errors were encountered: