Add support for numbered placeholders#725
Conversation
|
Related to #576 Could you add some more tests? What if there are gaps, e.g. See my comment here #576 (comment) |
|
@Prinzhorn I've added a couple of new testcases.
Semantically you should treat numbered placeholders the same as unnamed placeholders (?). It is just a shortcut to reuse the same bind values. For example, |
|
wow, it is still open I need to use the parameter multiple times, and it is a single parameter: It's stupid to wrap it into an object or pass it twice. But currently, I have no choice. |
|
SQLite better-sqlite3 initially didn’t know about this feature, so it might be difficult to implement it properly, especially in scenarios where mixing However, this is also my first time encountering But this is not a big problem. At worst, you can repackage an array or use named parameters directly. SQLite ?NNN 允许调整数据的绑定位置,这样可以复用数据并灵活绑定。?NNN 从 2004-09-18 (3.0.7) 开始支持 better-sqlite3 主要是一开始不知道这个特性,估计要支持很麻烦,特别是实现混编 ?、?NNN 和 命名参数 的场景。 不过我也是第一次知道 $NNN,以前写后端 jdbc 时就特别希望有这个特性(能调整绑定位置)这样就不用再封装一次数组以适应另一个 sql。 不过这也不是什么大问题,大不了重新包装一个数组,或者直接使用命名参数 |
This PR should add support for numbered placeholders (?1, ?2, ?3).
PS What
lzzis 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.