Enhanced placeholder/argument check algorithm

This commit is contained in:
Dave Morriss
2025-05-07 17:21:29 +01:00
parent 586c8e537e
commit bf8f6db45c
3 changed files with 18 additions and 14 deletions

View File

@@ -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";