fixed #476: Problem using execute and array parameters
Fixed issue #476: https://github.com/sidorares/node-mysql2/issues/476#issuecomment-264342349
This is a confusing issue, and I know that the two-step execution can greatly improve performance. But in cases where the statement contains an IN (?) this will cause some unexpected code failures. Many known issues are related to this.
In my opinion, the correctness of code is more important than performance. I suggest that when the SQL command contains IN (?), the formatter should be used first to format the command. Although this will lead to additional preparation processes, this simple modification can ensure that the code execution meets the expectations of most engineers in most cases.
Thanks for your excellent work!
It's now 2024, is there any update on this PR?
It's been a long time, but thanks @Leask 🤝
Regardless the performance, this PR needs a rebase to trigger all current tests. Also, it would be good to have additional tests covering these changes 🙋🏻♂️
In my opinion, the correctness of code is more important than performance.
About this, I believe that @sidorares can handle this discussion better.
Hi all! It's cool to be mentioned. It's been a long time. But if you guys can fix this, it will be excellent.
Based in https://github.com/sidorares/node-mysql2/issues/908#issuecomment-454168035, I suggest waiting for a conclusion from @sidorares before working on it 🙋🏻♂️
Notes
-
https://github.com/sidorares/node-mysql2/issues/796#issuecomment-397253582
-
https://github.com/sidorares/node-mysql2/issues/553#issuecomment-437221838
-
👌
Also consider updating the PR title, I believe the title is not helping either :P
Also consider updating the PR title, I believe the title is not helping either :P
Done 🤝
I'm open to discuss better DX here in general ( especially more helpful errors suggesting the fix ). However there is so many things that can potentially go wrong if we try to extract information from sql using a simple regex. Comments, strings, and many more scenarios can make the test incorrect.
Happy to continue discussion, but my vision in general:
- if logic requires understanding of sql structure, this logic needs full sql parser and should probably live somewhere in a higher level library using this driver ( ORM / routers etc )
- it's ok to have some code that tries to guess intention at an error handling level "did you mean field X" / "If the intention is to interpolate IN parameters, use this approach"