Closed Suor closed 8 years ago
The best solution I can see is supporting numbered placeholders and accurately shift their numbers:
'some_func($2, $1, $1)' -> 'some_func($5, $4, $4)'
Alternatively we can actively forbid $\d+
in sql, but that seems less intuitive.
@Suor: Yeah, I agree the current state is confusing -- previously I wasn't sure that number-shifting makes sense in all situations (I thought that maybe the user would expect the numbering to start at $4 if they had already supplied 3 parameters), but now that I think about it a little more, you're probably right that number-shifting is more intuitive.
I'd like to write out a few examples/scenarios and make sure number-shifting is intuitive for them.
Fixed in #85.
As far as I understand the correct way to use params in
sql()
now is using placeholders without numbers:This is fine, however, under current implementation this also works:
But if
stmt
had more params either via parametrizedsql()
or higher level methods it can both work erroneously or throw. Also, given that above works one could expect that these should also work:But they will also either fail or work erroneously.
All in all current state of affairs will eventually lead some users to some spectaculary confusing bugs.