Subject: | question about SQL::Interpolate |
Date: | Mon, 20 Jul 2015 18:13:55 +0000 |
To: | <bug-SQL-Interpolate [...] rt.cpan.org> |
From: | <Joseph.Norris [...] wellsfargo.com> |
First of all - thank you for this excellent module - I am having an issue with my unit tests and I was wondering if this would cause an issue:
elsif (ref $item eq 'HASH') {
$sql .=
" (" . join(', ', keys %$item) . ")"
" VALUES(" . join(', ', map {
_sql_interp_data($_);
} values %$item) . ")";
}
I made this change and all my tests and code work out:
$sql .=
" (" . join(', ', sort keys %$item) . ")" ;
$sql .= " VALUES(";
foreach my $idx ( sort keys %$item ){
$sql .= _sql_interp_data($item->{$idx}) . ',';
}
$sql =~ s/,$//;
$sql .= ")";
My unit tests were having changes to results because of no sort of the hash I would get this
DEBUG:interp[sql=insert into tbl (a, b) VALUES(?, ?),bind=1:2]
build_insert_repl_query: insert into tbl (a, b) VALUES(?, ?) $VAR1 = 1;
$VAR2 = 2;
$VAR1 = 'a';
$VAR2 = 1;
$VAR3 = 'b';
$VAR4 = 2;
ok 2 - t001 normal
ok 3 # skip 1
ok 4 # skip 1
ok
All tests successful.
and then later on this:
# Failed test 't001 normal'
# at db/build_insert_query.pm line 38.
# (in t::db::build_insert_query->t001_normal)
# got: 'insert into tbl (b, a) VALUES(?, ?)___2___1'
# expected: 'insert into tbl (a, b) VALUES(?, ?)___1___2'
Smartcard Access Management Developer
Cryptographic Services - Encryption & Tools Engineering Team | EIS | ETS | Corporate Risk | Wells Fargo
2600 South Price Road | Chandler, AZ 85286
MAC S3929-022
Office (480) 724-4744
joseph.norris@wellsfargo.com<mailto:joseph.norris@wellsfargo.com>
This message may contain confidential and/or privileged information. If you are not the addressee or authorized to receive this for the addressee, you must not use, copy, disclose, or take any action based on this message or any information herein. If you have received this message in error, please advise the sender immediately by reply e-mail and delete this message. Thank you for your cooperation.