From 877b741f30d1521cae3d5cc7e89f882773e29405 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 --- 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