-#!/usr/bin/perl
-
use strict;
use warnings;
use Test::More;
},
);
-
-plan tests => (@data * 5 + 2);
-
# test insert() and values() for reentrancy
my($insert_hash, $insert_array, $numfields);
my $a_sql = SQL::Abstract->new;
is ( $h_stmt, $insert_hash, 'Hash-based insert statement unchanged' );
is_deeply ( \@a_bind, \@h_bind, 'Bind values match after both insert() calls' );
- is_deeply ( [$h_sql->values ($record)] , \@h_bind, 'values() output matches bind values after insert()' );
+ is_deeply ( [$h_sql->values($record)] , \@h_bind, 'values() output matches bind values after insert()' );
is ( scalar @h_bind, $numfields, 'Number of fields unchanged' );
}
{
my $sql = SQL::Abstract->new;
- my $data = { event => 'rapture', time => \ 'now()', xfunc => \ '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);
+ my ($stmt, @bind) = $sql->insert('table', $data);
is_same_sql_bind (
$stmt,
\@bind,
- 'INSERT INTO table ( event, stuff, time, xfunc) VALUES ( ?, ?, now(), somefunc (?) )',
- [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)],
+ [$sql->values($data)],
[@bind],
'values() output matches that of initial bind'
) || diag "Corresponding SQL statement: $stmt";
}
+
+done_testing;