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

Dynamic insert multiple #355

Closed
g105b opened this issue Aug 14, 2023 · 2 comments · Fixed by #356
Closed

Dynamic insert multiple #355

g105b opened this issue Aug 14, 2023 · 2 comments · Fixed by #356
Assignees
Projects

Comments

@g105b
Copy link
Member

g105b commented Aug 14, 2023

It's slow to perform 20,000 insert queries, but fast to insert a query with 20,000 rows.

@g105b g105b added this to Backlog in Overview via automation Aug 14, 2023
@g105b g105b moved this from Backlog to WIP in Overview Aug 14, 2023
@g105b g105b self-assigned this Aug 14, 2023
@g105b
Copy link
Member Author

g105b commented Aug 14, 2023

If a bind value is passed of type array, this needs to trigger the special binder to inject a repeating query section.

One way it could do this is by detecting the brackets of the values part of the query, then converting it. Like the following:

Source SQL:

insert into User ( `id`, `name`, `email` )
values (:id, :name, :email)

Converted SQL:

insert into User ( `id`, `name`, `email` )
values (:id_00001, :name_00001, :email_00001),
(:id_00002, :name_00002, :email_00002),
(:id_00003, :name_00003, :email_00003),
(:id_00004, :name_00004, :email_00004),
(:id_00005, :name_00005, :email_00005)

@g105b
Copy link
Member Author

g105b commented Aug 15, 2023

Solution:

insert into User (`id`, `name`, `email`)
values ( :__dynamicValueset )

Expands into the converted SQL perfectly.

g105b added a commit that referenced this issue Aug 15, 2023
@g105b g105b mentioned this issue Aug 15, 2023
Overview automation moved this from WIP to Done September 2023 Sep 13, 2023
g105b added a commit that referenced this issue Sep 13, 2023
* feature: implement dynamic value set
closes #355

* tweak: dynamic value set syntax

* feature: implement dynamic in
closes #347

* tidy: dynamic injection

* wip: automatically wrap strings in single quotes

* tweak: remove unused variable

* tweak: double single quote for proper escaping

* feature: dynamic or
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Overview
Done September 2023
Development

Successfully merging a pull request may close this issue.

1 participant