Repository navigation
Conversation
a36f12e to
4d2550a
Compare
2173633 to
e86705a
Compare
janmeier
left a comment
There was a problem hiding this comment.
First of all, very nice and well worked out PR!
Is there any reason for hiding this behind a flag? I realize enabling it for all inserts would require a fair amount of tests to be rewritten, but I still think it would be a good idea.
| }; | ||
| expectsql(sql.insertQuery(User.tableName, values, User.rawAttributes, options), | ||
| { | ||
| mssql: 'INSERT INTO [users] ([user],[name]) VALUES ($1,UPPER(N\'bindtest\'));', |
There was a problem hiding this comment.
Ideally I'd like to assert on bind parameters as well. Something along the lines of
expectsql(sql..., {
query: {
....
}.
bind: [...]
})
There was a problem hiding this comment.
Good call - I'll do some tweaks shortly
|
Thanks @janmeier . I've put in a flag out of cautiousness - it also means anyone enabling the flag will be aware of the limitations of the current implementation. It could be enabled by default in a future version. |
|
@sequelize/orm WDYT? Should we hide this behind a flag? |
|
What are the limitations exactly? Of the top of my head I can't come up with any other than functions that might cause problems for inserts and you are already handling that |
|
Hmm if this is a flag, we theoretically would have to run the whole integration test suite twice, once enabled and once disabled. If it doesn't break any of the existing tests, I would have no fears to use it without a flag, or am I missing some edge-cases? |
|
Whilst I've named the option/flag Merging this won't add support for bind parameters to everywhere in the query generator, but having this behind a documented option gives users the benefit of bind parameters whilst ensuring they are aware of where it is supported. There's always a possibility to enable this option by default in the future. I don't think there should be a need to rerun the whole integration test suite twice - there are specific tests that target this option. |
e86705a to
a530a2f
Compare
|
I think what Erik is getting at is, that you remove the flag and run the full integration test suite with all its inserts again the new could we would have no problems releasing this without a flag. |
|
I think we should just remove this flag, even if we only support this for basic insert, there is no point hiding this behind the flag. If this works let's start using this feature. In next steps we can keep converting more parts of query generator to support bind parameters. |
|
At a brief glance 67 unit tests need updating to use the new format across the different dialects - I haven't looked at updating the integration tests yet. I'll see if I can get some time to make the changes. |
|
I've been playing a bit around with this and some changes will be required. Values don't need to be escaped when used as bind parameters. This applies to range (before: |
|
@janmeier I'd come to the same conclusion. I'm thinking of passing a function as a third param to the |
Sounds like a good idea! Ping me when you have something ready for review (or let me know if you need my help) |
|
Closing this PR as work is now continued in #9431 |
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
This provides very basic support for using bind parameters when generating INSERT queries and partly addresses #1608. Re-do of #8923