Perl::Critic::Policy::ValuesAndExpressions::PreventSQLInjection should not trigger on either:
my $sth = $dbh->prepare(q[
UPDATE `my_table` SET
`data` = ?
WHERE
`id` = ?
]);
$sth->execute( $new_data, $id )
or confess( "Update my_table failed. ($DBI::errstr)" );
or:
$dbh->do(q[
UPDATE `my_table` SET
`data` = ?
WHERE
`id` = ?
], undef, $new_data, $id)
or confess( "Update my_table failed. ($DBI::errstr)" );
The attached test file (which has an additional .txt to get around GitHub brain-damage) will pass when Perl::Critic::Policy::ValuesAndExpressions::PreventSQLInjection correctly handles the above cases; said test file is released under the Artistic 2.0 license (https://opensource.org/licenses/Artistic-2.0).
test_PreventSQLInjection_flagging_valid_constructs.t.txt
Perl::Critic::Policy::ValuesAndExpressions::PreventSQLInjectionshould not trigger on either:or:
The attached test file (which has an additional
.txtto get around GitHub brain-damage) will pass whenPerl::Critic::Policy::ValuesAndExpressions::PreventSQLInjectioncorrectly handles the above cases; said test file is released under the Artistic 2.0 license (https://opensource.org/licenses/Artistic-2.0).test_PreventSQLInjection_flagging_valid_constructs.t.txt