mirror of
https://github.com/DBD-SQLite/DBD-SQLite
synced 2025-06-07 14:19:10 -04:00
applied a patch by Yuriy Kaminskiy to fix binding named params
This commit is contained in:
parent
802e8d1548
commit
851134b13f
2 changed files with 24 additions and 2 deletions
2
dbdimp.c
2
dbdimp.c
|
@ -1150,8 +1150,8 @@ sqlite_bind_ph(SV *sth, imp_sth_t *imp_sth,
|
|||
sqlite_error(sth, -2, "InOut bind params not implemented");
|
||||
return FALSE; /* -> &sv_no in SQLite.xsi */
|
||||
}
|
||||
pos = 2 * (SvIV(param) - 1);
|
||||
}
|
||||
pos = 2 * (SvIV(param) - 1);
|
||||
sqlite_trace(sth, imp_sth, 3, form("bind into 0x%p: %"IVdf" => %s (%"IVdf") pos %d", imp_sth->params, SvIV(param), SvPV_nolen_undef_ok(value), sql_type, pos));
|
||||
av_store(imp_sth->params, pos, SvREFCNT_inc(value));
|
||||
if (sql_type) {
|
||||
|
|
|
@ -10,7 +10,7 @@ use t::lib::Test qw/connect_ok/;
|
|||
use Test::More;
|
||||
use Test::NoWarnings;
|
||||
|
||||
plan tests => 9;
|
||||
plan tests => 13;
|
||||
|
||||
my $dbh = connect_ok( RaiseError => 1 );
|
||||
ok $dbh->do('create table foo (id integer, value integer)');
|
||||
|
@ -19,6 +19,28 @@ ok $dbh->do('insert into foo values(?, ?)', undef, 1, 2);
|
|||
ok $dbh->do('insert into foo values(?1, ?2)', undef, 2, 3);
|
||||
ok $dbh->do('insert into foo values(:1, :2)', undef, 3, 4);
|
||||
ok $dbh->do('insert into foo values(@1, @2)', undef, 4, 4);
|
||||
my $sth = $dbh->prepare('insert into foo values(:foo, :bar)');
|
||||
ok $sth, "prepared sth with named parameters";
|
||||
$sth->bind_param(':foo', 5);
|
||||
$sth->bind_param(':bar', 6);
|
||||
my $warn;
|
||||
eval {
|
||||
local $SIG{__WARN__} = sub { $warn = shift; };
|
||||
$sth->bind_param(':baz', "AAAAAAA");
|
||||
};
|
||||
ok $@, "binding unexisting named parameters returns error";
|
||||
print "# expected bind error: $@";
|
||||
ok $warn, "... and warning";
|
||||
print "# expected bind warning: $warn";
|
||||
$sth->execute;
|
||||
{
|
||||
my ($count) = $dbh->selectrow_array(
|
||||
'select count(id) from foo where id = ? and value = ?',
|
||||
undef, 5, 6
|
||||
);
|
||||
|
||||
ok $count == 1, "successfully inserted row with named placeholders";
|
||||
}
|
||||
|
||||
SKIP: {
|
||||
skip "this placeholder requires SQLite 3.6.19 and newer", 2
|
||||
|
|
Loading…
Add table
Reference in a new issue