Skip to content

fix(oracle): For Raw queries avoid converting the input parameters passed - #16067

Merged
WikiRik merged 9 commits into
sequelize:v6from
sudarshan12s:RawqueryParams
Jun 1, 2023
Merged

WikiRik merged 9 commits into
sequelize:v6from
sudarshan12s:RawqueryParams

Conversation

@sudarshan12s

Copy link
Copy Markdown
Contributor

Pull Request Checklist

  • Have you added new tests to prevent regressions?
  • If a documentation update is necessary, have you opened a PR to the documentation repository?
  • Did you update the typescript typings accordingly (if applicable)?
  • Does the description below contain a link to an existing issue (Closes #[issue]) or a description of the issue you are solving?
  • Does the name of your PR follow our conventions?

Description Of Change

For Sequelize Raw queries such as below , the input bind value parameter, { one: 1, two: 2 } is converted to array [1,2] which is not required. Hence fixed code to avoid the same.

const result = await this.sequelize.query(select $one${typeCast} as foo, $two${typeCast} as bar${Support.addDualInSelect()}, { raw: true, bind: { one: 1, two: 2 }, logging(s) { logSql = s; } });

Todos

@WikiRik WikiRik 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.

Can you add a test for this?

@sudarshan12s

sudarshan12s commented May 26, 2023 •

Copy link
Copy Markdown
Contributor Author

Can you add a test for this?

Can you add a test for this?

Yes. changed the existing test case. The issue happened when bind values were sent as array and they are treated like replacements (?) . I modified the existing test case to change the order of bind names like ' select :one as foo, :one as bar, :two as baz FROM DUAL' instead of 'select :one as foo, :two as bar, :one as baz FROM DUAL'. The test fails with Oracle dialect with error 'ORA-01008: not all variables bound' . With the fix to retain the bind values as it is { one: 1, two: 2 } , the test case passed.

@WikiRik
WikiRik merged commit fd38e79 into sequelize:v6 Jun 1, 2023
@github-actions

github-actions Bot commented Jun 1, 2023

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 6.32.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants