-
Notifications
You must be signed in to change notification settings - Fork 34
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
Batch INSERT (using array of arrays) results in the application hanging #261
Comments
Hi @jpmnteiro! I tried your snippet, and indeed it fails when you pass an array of arrays. The error is a bit obscure, though ( I think your app seems to "hang" because you don't handle the promise returned from For arrays as parameters: currently, only primitive values are supported as parameters. It's a limitation of the server, the library just follows it. But even when one day server will support complex type values - you still cannot do batch inserts like you wanted initially. Every placeholder matches a single value, even if the value is an array. Arrays will not get expanded as a multiple parameters, the whole array will be used as a value. For batch inserts you have to do exactly what you did as a workaround - add multiple placeholders and bind multiple values to them. Lastly, I would highly recommend you to use a proper IDE. For example, IntelliJ IDEA can warn you about mishandling the result of |
Cool, definitely worth having less obscure errors.
The code I posted is merely illustrative (I missed the await there), the actual app code awaits the call.
That's quite unfortunate, considering other drivers out there do a sensible approach and turn the array of arrays into a multi-value insert. Maybe worth updating the documentation to state that this is not a supported case (and offer a workaround?).
I appreciate the suggestion, even if it does come across a little bit condescending. VsCode and eslint also catch the issue (which is not an issue as I explained above).
That's not quite right actually, considering that the TS type checker infers that your DBSQLParameterValue is an Thank you for taking the time to reply! |
Hey!
I'm trying to parameterise an INSERT statement and feeding
executeStatement
an array of arrays so that I can batch INSERTs into a table.However, it seems like instead of working (or failing), the driver never responds and the application just hangs.
Example:
If I fully create the INSERT query,
INSERT INTO test(id) values (1), (2), (3)
, it works just fine.I had a look at how
executeStatement
handles parameters and it doesn't seem to support arrays of arrays, so I am at loss of how to batch insert with parameterisation.Env:
The text was updated successfully, but these errors were encountered: