From 54512de63040213c56716d9b8b2a91bdb5a7216e Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 12 Feb 2020 11:27:39 +0100 Subject: [PATCH] Bug 13897: Surround columns with backticks We have some column's names that need to be surrounded by ` as they are protected keywords ('rows' for instance) Signed-off-by: Martin Renvoize Signed-off-by: Jonathan Druart --- C4/Installer.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/C4/Installer.pm b/C4/Installer.pm index 2e096279d3..012bc1c3cd 100644 --- a/C4/Installer.pm +++ b/C4/Installer.pm @@ -486,7 +486,7 @@ sub load_sql { my $table_name = ( keys %$table )[0]; # table name my @rows = @{ $table->{$table_name}->{rows} }; # my @columns = ( sort keys %{$rows[0]} ); # column names - my $fields = join ",", @columns; # idem, joined + my $fields = join ",", map{sprintf("`%s`", $_)} @columns; # idem, joined my $placeholders = join ",", map { "?" } @columns; # '?,..,?' string my $query = "INSERT INTO $table_name ( $fields ) VALUES ( $placeholders )"; my $sth = $dbh->prepare($query); -- 2.20.1