Skip to content
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

Support Array of values for bulk inserts #17

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

volkmarnissen
Copy link

This fix avoids locked objects when inserting multiple rows to the same table by firing multiple query requests.
The queries can run at the same time and generate locking errors.

Example: msg.payload contains array of objects to insert.
A split node generates an single payload for each of them and passes them to the mysql node.
You might get lock errors, because all values will be executed in paralell

It's better to execute all inserts in one statements and in one transaction.

If the payload, contains an array, all objects in that array will be processed in one transaction.
No split node is required.
if the payload contains an object, it's treated as an array with one entry.

Example topic and payload

msg.topic = "insert into test (date_hour, price) " +
    "select :hour, :price  from dual where not exists( select hour from test where " +
    "hour =:hour);\n"

msg.payload  = [{ date_hour: 1234, price:0.234},{ date_hour: 12345, price:0.235}]
return msg;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants