From fda562a28a672089d65ba35714cb6e885ac73cc0 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) --- C4/Installer.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/C4/Installer.pm b/C4/Installer.pm index 02a72552ed..b8131c8a5b 100644 --- a/C4/Installer.pm +++ b/C4/Installer.pm @@ -487,7 +487,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.11.0