Skip to content

feat: use bind params in bulkInsertQuery - #17128

Closed
Americas wants to merge 1 commit into
sequelize:v6from
Americas:v6
Closed

Americas wants to merge 1 commit into
sequelize:v6from
Americas:v6

Conversation

@Americas

Copy link
Copy Markdown
Contributor

Description of Changes

When using bulk create, the generated SQL does not use bindings. This creates an issue, since the data is logged along with the running query.

With this PR, the default generated SQL for a bulk insert will use bindings by default, unless replacements is being used, or bindParams is false.

List of Breaking Changes

  • abstract QueryGenerator.bulkInsertQuery() now returns an object with 2 properties: query (always returned) and bind (only if bind params are used)

@ephys ephys left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm sorry but it's too late in v6 to introduce breaking changes

We also require changes to be done against v7 first, then backported when possible

We plan on adding support for bind parameters on almost all queries using an option in a future update (v7+). See #11586 (comment)

@ephys ephys closed this Feb 27, 2024
@Americas

Copy link
Copy Markdown
Contributor Author

Please note that this BC is on an internal API, nothing breaks externally..

I can also work on implementing the same change on the v7 branch.

@ephys

ephys commented Mar 17, 2024 •

Copy link
Copy Markdown
Member

Sadly it's not very well indicated as an internal API and there is a decent chance that some people used this function directly

We've been working on blocking access to internal APIs in v7, and making the query generator a public API (parts of it, at least)

As a intermediary solution, what we could do is add support for the parameterStyle: 'bind' | 'replacement' option. If the type is 'replacement', then it returns a string. Otherwise, it returns { sql, bind }

parameterStyle would have to default to replacement in v6, but can default to bind in v7

If that works for you, I can reopen this PR. I apologize for closing it this quickly. That was disrespectful of me

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.

2 participants