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

feat(query-generator): Generate UPDATEs using bind parameters #9492

Merged
merged 1 commit into from Jun 7, 2018

Conversation

@gazoakley
Copy link
Contributor

@gazoakley gazoakley commented May 30, 2018

Pull Request check-list

Please make sure to review and check all of these items:

  • Does npm run test or npm run test-DIALECT pass with this change (including linting)?
  • Does the description below contain a link to an existing issue (Closes #[issue]) or a description of the issue you are solving?
  • Have you added new tests to prevent regressions?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Did you follow the commit message conventions explained in CONTRIBUTING.md?

Description of change

Changes to allow UPDATEs to use bind parameters instead of directly included values. For example, instead of:

UPDATE `myTable` SET `name`='foo',`birthday`='2011-03-27 10:01:55' WHERE `id` = 2

Generate:

UPDATE `myTable` SET `name`=$1,`birthday`=$2 WHERE `id` = $3

(with parameters 'foo', '2011-03-27 10:01:55' and 2)

@gazoakley gazoakley force-pushed the gazoakley:feat-update-bind branch from c8b94c1 to 52aecbc May 30, 2018
@gazoakley gazoakley force-pushed the gazoakley:feat-update-bind branch from 52aecbc to d9cf786 May 31, 2018
@codecov
Copy link

@codecov codecov bot commented May 31, 2018

Codecov Report

Merging #9492 into master will decrease coverage by 0.02%.
The diff coverage is 100%.

@gazoakley gazoakley force-pushed the gazoakley:feat-update-bind branch 3 times, most recently from 62ec295 to 432f567 May 31, 2018
@gazoakley gazoakley changed the title [WIP] feat(query-generator): Generate UPDATEs using bind parameters feat(query-generator): Generate UPDATEs using bind parameters May 31, 2018
Copy link
Contributor

@sushantdhiman sushantdhiman left a comment

Looks good overall, would like comments from other members

const Type = new Sequelize.STRING();

if (dialect === 'mssql') {

This comment has been minimized.

@sushantdhiman

sushantdhiman Jun 5, 2018
Contributor

Why only mssql?

This comment has been minimized.

@gazoakley

gazoakley Jun 5, 2018
Author Contributor

mssql has a _bindParam function that outputs either a Buffer or a normal string dependent on whether or not the STRING data type uses the binary param. This override isn't needed for other dialects - I've added a comment.

@@ -984,8 +984,8 @@ describe(Support.getTestDialectTeaser('Model'), () => {
return user.save({
logging(sql) {
test = true;
expect(sql).to.contain('ARRAY[]::INTEGER[]');
expect(sql).to.contain('ARRAY[]::VARCHAR(255)[]');
expect(sql).not.to.contain('ARRAY[]::INTEGER[]');

This comment has been minimized.

@sushantdhiman

sushantdhiman Jun 5, 2018
Contributor

These tests should be moved to unit tests, but that is too much work, should be tackled in different PR. Please add some assertion which covers what is expected here, like may be just ARRAY[]?

@sushantdhiman sushantdhiman removed the wip label Jun 5, 2018
@sushantdhiman sushantdhiman requested review from janmeier and eseliger Jun 5, 2018
@gazoakley gazoakley force-pushed the gazoakley:feat-update-bind branch from 432f567 to 207c6d3 Jun 5, 2018
@sushantdhiman sushantdhiman merged commit 9b1ca37 into sequelize:master Jun 7, 2018
4 checks passed
4 checks passed
codecov/patch 100% of diff hit (target 95.97%)
Details
codecov/project Absolute coverage decreased by -0.02% but relative coverage increased by +4.02% compared to 6f15849
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@gazoakley
Copy link
Contributor Author

@gazoakley gazoakley commented Jun 7, 2018

@sushantdhiman
Copy link
Contributor

@sushantdhiman sushantdhiman commented Jun 7, 2018

Thanks for this contribution @gazoakley , This is an important missing feature from Sequelize

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants