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

Add support for numbered placeholders #725

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

Conversation

alex3d
Copy link

@alex3d alex3d commented Nov 15, 2021

This PR should add support for numbered placeholders (?1, ?2, ?3).

PS What lzz is assumed to be used with this project? https://github.com/mjspncr/lzz3? https://github.com/driedfruit/lzz? Probably this info could be added to the readme.

@alex3d alex3d requested a review from JoshuaWise as a code owner November 15, 2021 08:32
@Prinzhorn
Copy link
Contributor

Related to #576

Could you add some more tests? What if there are gaps, e.g. SELECT ?3, ?15? How do you bind that? With an array or object? Or do both work?

See my comment here #576 (comment)

@alex3d
Copy link
Author

alex3d commented Nov 25, 2021

@Prinzhorn I've added a couple of new testcases.

How do you bind that? With an array or object? Or do both work?

Semantically you should treat numbered placeholders the same as unnamed placeholders (?). It is just a shortcut to reuse the same bind values. For example, INSERT INTO payments(payment_type, amount) VALUES (?1, ?), (?1, ?) + bind values ['cash', 100, 200].
? === increment current_index and insert anonymous bind value with index current_index
?n === insert anonymous bind value with index n and set current_index = max(current_index, n)

@7nik
Copy link

7nik commented Apr 15, 2023

wow, it is still open

I need to use the parameter multiple times, and it is a single parameter:
WHERE instr(lower(card.name), ?1) OR instr(lower(card.description), ?1)

It's stupid to wrap it into an object or pass it twice. But currently, I have no choice.

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

Successfully merging this pull request may close these issues.

4 participants