Skip to content

Problem on sequelize.where function with correctly placing % operators. #13753

Closed

Description

@amitrana-dev

Issue Creation Checklist

[x] I have read the contribution guidelines

Bug Description

Sequalize.where isn't placing % operators on startsWith, endsWith & substring operations.

SSCCE

Here is the link to the SSCCE for this issue: #202

JS Code

const Foo = sequelize.define('Foo', { name: DataTypes.TEXT });
await Foo.create({ name: 'foo' })
Foo.count({where: { [Op.and]: [ Sequelize.where(Sequelize.col('name'),Op.startsWith,'fo') ] } })

What do you expect to happen?

Expected query should be:

SELECT count(*) AS count FROM Foos AS Foo WHERE (name LIKE 'fo%');

What is actually happening?

Actual query generated is:

SELECT count(*) AS count FROM Foos AS Foo WHERE (name LIKE 'fo');

Environment

  • Sequelize version: 6.11.0
  • Node.js version: v14.17.0

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 mysql, with connector library version [email protected] and database version 5.7.29

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.

Activity

  1. changed the title [-]Problem on sequelize.where function with placing correct % operators.[/-] [+]Problem on sequelize.where function with correctly placing % operators.[/+] on Dec 9, 2021
  2. github-actions commented on Dec 24, 2021

    @github-actions
    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. 🙂

  3. amitrana-dev commented on Dec 24, 2021

    @amitrana-dev
    Author

    Up

  4. self-assigned this
    on Dec 29, 2021
  5. github-actions commented on Jan 13, 2022

    @github-actions
    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. 🙂

  6. github-actions commented on Jan 28, 2022

    @github-actions
    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. 🙂

  7. added
    type: bug
    on Jan 28, 2022
  8. added
    topic: operators
    on Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

topic: operatorstype: bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions