Skip to content

Support for bind parameters #11586

Open

Description

@mschipperheyn

There is a PR (#10284) for bind parameters on SELECT statements in sequelize, a crucial performance related feature. However, it is floundering.

I would like to propose to make this feature an explicit goal of v6. This way it gets the focus and priority it requires.

On a separate note, I think any sequelize version should have an umbrella task that allows debate on priorities and a checkable list of references to individual features.

Issue Description

Support bind parameters across the board

Is your feature request related to a problem? Please describe.

Bind parameters optimize performance and are an expected baseline for modern ORMs.

Describe the solution you'd like

Ideally, I would like bind parameters to be a global option that would allow you to have bind parameters use the already existing { someId: { [Op.eq]: var } style code, and a query specific option to override the default.

Alternatively, a different syntax could be considered (as is the case with Hibernate) to make the use case explicitly separate.

Why should this be in Sequelize

Performance.
It is expected by people deciding on framework use.

Describe alternatives/workarounds you've considered

I've considered moving to TypeORM because of this. But I'm more familiar with sequelize and my code is in sequelize. I would pref it to be available on sequelize.

Is this issue dialect-specific?

  • No. This issue is relevant to Sequelize as a whole.
  • Yes. This issue only applies to the following dialect(s): XXX, YYY, ZZZ

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

It's already been done, but likely needs to be re-aligned.

  • 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. papb commented on Oct 20, 2019

    @papb
    Member

    Thank you. I agree.

  2. added
    P1: important
    status: wip
    type: feature
    on Oct 20, 2019
  3. papb commented on Oct 20, 2019

    @papb
    Member

    @sushantdhiman Should we add this to the v6 milestone?

  4. javiertury commented on Jan 25, 2020

    @javiertury
    Contributor

    I appreciate your interest for pull request #10284 about adding bind parameters. Unfortunately, during the last year I migrated all my projects to another sql library. The reason is that, despite all the effort and time I put on sequelize, I didn't see any progress at all, which is frustrating.

    You can still find the bind-params branch in my repo. Feel free to use it as a starting point, just keep in mind that it's a little bit outdated.

  5. papb commented on Jan 26, 2020

    @papb
    Member

    Hi @javiertury, thank you again for all the effort you made here. Hopefully at some point I will be able to continue from where you stopped (if no one does it first). Thanks!!

  6. mschipperheyn commented on Jan 26, 2020

    @mschipperheyn
    Author

    @javiertury What library did you migrate to? TypeORM? I'm also considering moving away for the same reason. There seems to be 0 interaction with the community about priorities and choices. Extremely disappointing. Sequelize seems to have become a @sushantdhiman one man show with a focus on very small steps.

  7. javiertury commented on Jan 26, 2020

    @javiertury
    Contributor

    @mschipperheyn, first I want to clarify my point of view. I don't think that @sushantdhiman is at fault, it's hard to be a maintainer of large projects like this. There are many trade offs: a stable interface, new features, robustness, etc.

    I think of it as a mismatch of goals. Sequelize is a conservative library and I needed flexibility, that's why I switched to Objection ORM + knex. It's more complicated to use, but I can add all the features I need using 3rd party plugins or develop my own.

    Finally, I won't answer more offtopic questions in this thread. Nothing personal, don't get offended.

  8. mschipperheyn commented on Jan 26, 2020

    @mschipperheyn
    Author

    Fair enough. I might be overly negative. But it's the vibe I'm getting. Thanks for sharing your point of view.

  9. github-actions commented on Nov 6, 2021

    @github-actions
    Contributor

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

  10. ephys commented on Apr 25, 2022

    @ephys
    Member

    Properly supporting bind parameters is a priority of mine, I have a few bind-related tasks in my backlog.

    With #14447 and #14020, we'll be able to use bind parameters in many places easily like this:

    User.findAll({
      where: { id: literal('$id') },
      bind: { id: 5 },
    });

    With more good things to follow such as caching queries using prepared statements & bind parameters, and specifying the type of a bind parameter.

    A global option like in update and insert could follow if there is interest, but it's incompatible with the planned API design for prepared statements.

  11. ephys commented on Feb 20, 2023

    @ephys
    Member

    I have an update on this.
    We've done a lot of internal work and I believe we'll be able to add the global option I mentioned in the above post. That option will let you choose whether a given query will use bind parameters or replacements.

    Something like this:

    User.findAll({
      where: { id: 5 },
      // The exact option name & values are not defined yet
      parameterStyle: 'bind',
    });
    
    User.create({ id: 5 }, {
      // The exact option name & values are not defined yet
      parameterStyle: 'replacement',
    });
  12. changed the title [-]V6: Support for bind parameters[/-] [+]Support for bind parameters[/+] on Feb 20, 2023
  13. added theissue type on Mar 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1: importantstatus: wiptype: feature

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions