X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F03values.t;h=c0ec9cc655cf5fa02ebcd02c394e81fcf84b04a2;hb=4f30591bc0678f8a5d657e79c6985606b064cd1d;hp=f88debb25702f8d33b27cba26521d5f3e03db9c7;hpb=35d55ea7e12edefbb9cffb9c66ae12cdfaa2c839;p=scpubgit%2FQ-Branch.git diff --git a/t/03values.t b/t/03values.t index f88debb..c0ec9cc 100644 --- a/t/03values.t +++ b/t/03values.t @@ -85,23 +85,37 @@ for my $record (@data) { } # test values() with literal sql +# +# NOTE: +# The example is deliberately complicated by the addition of a literal ? in xfunc +# This is an intentional test making sure literal ? remains untouched. +# It is rather impractical in the field, as the user will have to insert +# a bindvalue for the literal position(s) in the correct offset of \@bind { my $sql = SQL::Abstract->new; - my $data = { event => 'rapture', time => \ 'now()', func => \ 'somefunc(?)', stuff => 'fluff', }; + my $data = { + event => 'rapture', + stuff => 'fluff', + time => \ 'now()', + xfunc => \ 'xfunc(?)', + yfunc => ['yfunc(?)', 'ystuff' ], + zfunc => \['zfunc(?)', 'zstuff' ], + zzlast => 'zzstuff', + }; my ($stmt, @bind) = $sql->insert ('table', $data); is_same_sql_bind ( $stmt, \@bind, - 'INSERT INTO table ( event, func, stuff, time) VALUES ( ?, somefunc (?), ?, now() )', - [qw/rapture fluff/], # event < stuff + 'INSERT INTO table ( event, stuff, time, xfunc, yfunc, zfunc, zzlast) VALUES ( ?, ?, now(), xfunc (?), yfunc(?), zfunc(?), ? )', + [qw/rapture fluff ystuff zstuff zzstuff/], # event < stuff ); is_same_bind ( [$sql->values ($data)], - [\@bind], + [@bind], 'values() output matches that of initial bind' - ); + ) || diag "Corresponding SQL statement: $stmt"; }