sequelize / sequelize-auto

Automatically generate bare sequelize models from your database.
2.9k stars 527 forks source link

fix quote for default value #643

Open Aha00a opened 1 year ago

Aha00a commented 1 year ago

I'm sorry and thank you for your sharing.

This PR is about default value.

I have field that uses single quote in default clause,

  `id` binary(16) NOT NULL DEFAULT unhex(replace(uuid(),'-','')) COMMENT 'identifier',

then it generates

      defaultValue: Sequelize.Sequelize.literal('unhex(replace(uuid(),'-',''))'),

then it causes error.

I've tried DEFAULT unhex(replace(uuid(),"-","")), but MariaDB converts " to '.

I always think thanking you when I use sequelize-auto, please consider this.

Best regards.

mariusa commented 1 year ago

Besides the fix, this should also be considered: https://github.com/sequelize/sequelize-auto/issues/592