Closed ghost closed 9 years ago
Though it may be confusable, it isn't a bug. If you bind placeholders by number, they are bound by their positions, not by their names even thought they are numbered.
First, I don't accept your patch because the following code doesn't work if it is applied.
conn.exec('select * from emp where ename = :ename', 'Smith')
Second, I won't introduce such incompatibility to ruby-oci8 even if special handling is added for numbered plalceholders by checking their names. Old ruby code using ruby-oci8 may be broken by the incompatibility.
Agreed, that it would be an incompatible change. Thanks for your quick response.
I think that the way that numbered SQL placeholders are bound, should be changed. The problem is that:
when you would expect
["second", "first"]
. This results from the use of OCIBindByPos() in stmt.c when the vplaceholder has type FIXNUM, because OCIBindByPos ignores the placeholder names. This can cause problems with duplicated placeholders, as well. For example,but
returns no rows.
It is possible to work around this by using the bind_param() method and converting keys to strings. This causes OCIBindByName() to be used, producing the result that I would expect:
The following change to stmt.c fixes the problem, but only for eight-bit character encodings. I do not know how to do a FIXNUM to C-string conversion that would also work for wide characters.