Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix quote for default value #643

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Aha00a
Copy link

@Aha00a Aha00a commented Mar 16, 2023

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.

Copy link
Member

@ephys ephys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would only displace the problem, not fix it. If the value includes a double quote, you're going to end up with the same problem

The only way to fix this would be to escape inner quotes

@mariusa
Copy link

mariusa commented Apr 22, 2023

Besides the fix, this should also be considered: #592

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants