Enhanced placeholder/argument check algorithm
This commit is contained in:
@@ -28,7 +28,7 @@
|
||||
# AUTHOR: Dave Morriss (djm), Dave.Morriss@gmail.com
|
||||
# VERSION: 0.0.8
|
||||
# CREATED: 2021-06-18 13:24:49
|
||||
# REVISION: 2025-05-06 16:39:25
|
||||
# REVISION: 2025-05-07 17:19:15
|
||||
#
|
||||
#===============================================================================
|
||||
|
||||
@@ -164,11 +164,16 @@ else {
|
||||
_debug( $DEBUG >= 3, '$query: ' . Dumper(\$query) );
|
||||
|
||||
#
|
||||
# Count placeholders in the query and the arguments provided
|
||||
# Count placeholders in the query and the arguments provided. First remove all
|
||||
# comments which may contain '?' characters, then count any that are left.
|
||||
#
|
||||
$query = join("\n", grep {!/^--/} split( "\n", $query ) );
|
||||
$pcount = grep {/\?/} split( '', $query );
|
||||
$acount = scalar(@dbargs);
|
||||
|
||||
#
|
||||
# Check the placeholder and argument counts are the same
|
||||
#
|
||||
if ( $pcount ne $acount) {
|
||||
say STDERR "Query placeholder vs argument mismatch";
|
||||
say STDERR "Placeholders = $pcount, Arguments = $acount";
|
||||
|
Reference in New Issue
Block a user