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

Very strange error in conact function with dollar sign #13772

Closed
2 of 7 tasks
moonjoungyoung opened this issue Dec 14, 2021 · 4 comments
Closed
2 of 7 tasks

Very strange error in conact function with dollar sign #13772

moonjoungyoung opened this issue Dec 14, 2021 · 4 comments
Assignees
Labels
existing workaround For issues. There is a known workaround for this issue. type: bug

Comments

@moonjoungyoung
Copy link

moonjoungyoung commented Dec 14, 2021

Issue Creation Checklist

[X] I have read the contribution guidelines

Bug Description

SSCCE

Here is the link to the SSCCE for this issue: LINK-HERE

// model
  model.beforeFind((options) => {
    if (options.where && options.where.password && typeof (options.where.password) === 'string') {
      console.log('options.where.password', options.where.password);
      options.where.password = sequelize.fn('CONCAT', options.where.password, sequelize.col('id'));
    }
  });

// controller
  await Model.findAll({
    where: {
      id: 123,
      password: '123$123',
    },
    logging: console.log,
  });

// console
options.where.password 123$123

Executing (default):
SELECT `id`, `password`, `deletedAt`
FROM `_person` AS `_person`
WHERE (`_person`.`deletedAt` IS NULL AND (`_person`.`id` = '123' AND `_person`.`password` = CONCAT('123$$123', `id`)));

What do you expect to happen?

I expect SQL seems CONCAT('123$123', `id`)

What is actually happening?

SQL is CONCAT('123$$123', `id`);
ONE DOLLAR SIGN HAS ADDED!!

Additional context

Add any other context and details here.

Environment

  • Sequelize version: 6.9.0
  • Node.js version: 12.22.3

Bug Report Checklist

How does this problem relate to dialects?

  • I think this problem happens regardless of the dialect.
  • I think this problem happens only for the following dialect(s):
  • I don't know, I was using PUT-YOUR-DIALECT-HERE, with connector library version XXX and database version XXX

Would you be willing to resolve this issue by submitting a Pull Request?

  • Yes, I have the time and I know how to start.
  • Yes, I have the time but I don't know how to start, I would need guidance.
  • No, I don't have the time, although I believe I could do it if I had the time...
  • No, I don't have the time and I wouldn't even know how to start.
@github-actions
Copy link
Contributor

This issue has been automatically marked as stale because it has been open for 14 days without activity. It will be closed if no further activity occurs within the next 14 days. If this is still an issue, just leave a comment or remove the "stale" label. 🙂

@github-actions github-actions bot added the stale label Dec 29, 2021
@WikiRik WikiRik added type: bug and removed stale labels Dec 29, 2021
@WikiRik WikiRik self-assigned this Dec 29, 2021
@WikiRik
Copy link
Member

WikiRik commented Dec 29, 2021

Upon initial analysis, this is due to the string with the dollar sign being one of the fn arguments. Will have to investigate further, but I can reproduce this error.

@WikiRik WikiRik added the existing workaround For issues. There is a known workaround for this issue. label Dec 30, 2021
@WikiRik
Copy link
Member

WikiRik commented Dec 30, 2021

This is due to #11606. Not sure if this is something we can fix properly, but there is a workaround in the form of sequelize.literal()

So you can use

options.where.password = sequelize.fn('CONCAT', sequelize.literal(options.where.password), sequelize.col('id'));

@WikiRik
Copy link
Member

WikiRik commented Jan 13, 2022

Closed in favor of #12523

@WikiRik WikiRik closed this as completed Jan 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
existing workaround For issues. There is a known workaround for this issue. type: bug
Projects
None yet
Development

No branches or pull requests

2 participants