better-sqlite3
better-sqlite3 copied to clipboard
Add support for numbered placeholders
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.
Related to https://github.com/JoshuaWise/better-sqlite3/issues/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 https://github.com/JoshuaWise/better-sqlite3/issues/576#issuecomment-804976406
@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)
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.