-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Accept an object as first parameter in execute
et al.
#1629
Comments
execute
et. al.execute
et al.
HI @PhilippSalvisberg |
I was referring to the sql-template-tag version. ;-)
Sounds promising. Thank you. |
Hi @PhilippSalvisberg ,
I noted the following while i was testing the same with the sql-template-tag module
|
Hi @sudarshan12s, If you can provide me with a compiled version that runs on macOS Silicon, I'd be happy to try it out. No problem, If this is not possible/too complicated. I will test it once 6.4 is released. Thank you for including this change. |
Hi @PhilippSalvisberg All you need to do is the following:
Since this is a JavaScript change, there is no need for any compile. If it is still too complicated or if there are other issues arising from integrating this file, it will be available in the 6.4 release. |
Works, but I had to change the signature for from execute<T>(sql: string): Promise<Result<T>>; to execute<T>(sql): Promise<Result<T>>; or execute<T>(sql: string|unknown): Promise<Result<T>>; to avoid an |
So, besides the change of the driver, this file/line needs to be patched as well when working with TypeScript. |
Looks to me like a new Interface needs to be added and another option for execute() added instead. Your solution works but leaves the interface undefined -- a good stopgap solution but not a good final one! |
Thanks @PhilippSalvisberg for pointing it out. We will check on updating the types definition.. |
Thanks, @sudarshan12s for taking care of the TypeScript types definitions. Very much appreciated. |
@PhilippSalvisberg This is now available in node-oracledb 6.4. We have raised a PR for the TypeScript update |
The type definition change PR is here. |
By the way, this is now also part of mle-js-oracledb, i.e. for In-Database JavaScript in Oracle 23.5: |
Perfect. Thanks @lucasbraun |
The popular npm module sql-template-tag supports oracledb in the latest version 5.2.0. So we can write code like this:
However, I'd like to make the code more compact. Similar to MySQL and PostgreSQL. Something like this:
To make it work, the
execute
function and related functions need to accept a JSON object as first parameter. Similar to the implementation in MySQL forquery
. The object contains astatement
field with positional bind parameters for oracledb. The bind values are provided in thevalues
field.IMO this would improve the usability in a backward-compatible way. Making the use of bind parameters as simple as in MySQL and PostgreSQL.
Using the sql-template-tag makes template literals containing large SQL statements easy to read, even with positional bind parameters. It's similar to static SQL in PL/SQL. This makes the use of named bind parameters in a lot of cases unnecessary.
The text was updated successfully, but these errors were encountered: