Skip to content

Commit 2870fe0

Browse files
committed
Make ParamValues follow expectations
1. The keys are expected (not guaranteed) to be integers starting at 1. They previously started at 0. 2. The values should be undef if not yet bound
1 parent 0c8c2d3 commit 2870fe0

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

dbdimp.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4026,9 +4026,16 @@ dbd_st_FETCH_internal(
40264026
I32 keylen;
40274027
for (n= 0; n < DBIc_NUM_PARAMS(imp_sth); n++)
40284028
{
4029-
keylen= sprintf(key, "%d", n);
4030-
(void)hv_store(pvhv, key,
4031-
keylen, newSVsv(imp_sth->params[n].value), 0);
4029+
// https://metacpan.org/pod/DBI#ParamValues says keys
4030+
// are typically integers starting at 1
4031+
// values should be undef if not yet bound
4032+
keylen= sprintf(key, "%d", n+1);
4033+
if (imp_sth->params[n].value) {
4034+
(void)hv_store(pvhv, key,
4035+
keylen, newSVsv(imp_sth->params[n].value), 0);
4036+
} else {
4037+
(void)hv_store(pvhv, key, keylen, &PL_sv_undef, 0);
4038+
}
40324039
}
40334040
}
40344041
retsv= sv_2mortal(newRV_noinc((SV*)pvhv));

0 commit comments

Comments
 (0)