Repository navigation
feat(query-generator): Generate UPDATEs using bind parameters - #9492
Conversation
c8b94c1 to
52aecbc
Compare
52aecbc to
d9cf786
Compare
62ec295 to
432f567
Compare
sushantdhiman
left a comment
There was a problem hiding this comment.
Looks good overall, would like comments from other members
| it('calls parse and stringify/bindParam for STRING', () => { | ||
| const Type = new Sequelize.STRING(); | ||
|
|
||
| if (dialect === 'mssql') { |
There was a problem hiding this comment.
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.
| test = true; | ||
| expect(sql).to.contain('ARRAY[]::INTEGER[]'); | ||
| expect(sql).to.contain('ARRAY[]::VARCHAR(255)[]'); | ||
| expect(sql).not.to.contain('ARRAY[]::INTEGER[]'); |
There was a problem hiding this comment.
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[]?
There was a problem hiding this comment.
I've tidied this up a bit:
- https://github.com/sequelize/sequelize/pull/9492/files#diff-4b224bbc09dfb867f8671d77e298bb8cR955
- https://github.com/sequelize/sequelize/pull/9492/files#diff-4b224bbc09dfb867f8671d77e298bb8cR955
432f567 to
207c6d3
Compare
|
@sushantdhiman @janmeier Thanks 🎉 |
|
Thanks for this contribution @gazoakley , This is an important missing feature from Sequelize |
Pull Request check-list
Please make sure to review and check all of these items:
npm run testornpm run test-DIALECTpass with this change (including linting)?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` = 2Generate:
UPDATE `myTable` SET `name`=$1,`birthday`=$2 WHERE `id` = $3(with parameters
'foo','2011-03-27 10:01:55'and2)