Bugzilla – Attachment 101079 Details for
Bug 24912
Generate SQL from YAML installer files
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24912: Move to a flat array with all values to an array of arrayref
Bug-24912-Move-to-a-flat-array-with-all-values-to-.patch (text/plain), 2.17 KB, created by
Jonathan Druart
on 2020-03-20 11:20:12 UTC
(
hide
)
Description:
Bug 24912: Move to a flat array with all values to an array of arrayref
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2020-03-20 11:20:12 UTC
Size:
2.17 KB
patch
obsolete
>From 276c747175652e1f0d94572c16da1a23bb52a73c Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 19 Mar 2020 12:20:23 +0100 >Subject: [PATCH] Bug 24912: Move to a flat array with all values to an array > of arrayref > >For the following SQL query: >INSERT INTO cities(city_name, city_country) VALUES ('Madrid', 'Spain'), ('Buenos Aires', 'Argentina'); > >We move from: >[ 'Madrid', 'Spain', 'Buenos Aires', 'Argentina' ] >to: >[ [ 'Madrid', 'Spain' ], [ 'Buenos Aires', 'Argentina' ] ] > >Which make more sense to split, build and construct the queries >--- > C4/Installer.pm | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) > >diff --git a/C4/Installer.pm b/C4/Installer.pm >index a7ca5d807b..b9a0ce53b2 100644 >--- a/C4/Installer.pm >+++ b/C4/Installer.pm >@@ -470,12 +470,12 @@ sub process_yml_table { > my $placeholders = '(' . join ( ",", map { "?" } @columns ) . ')'; # '(?,..,?)' string > my @values; > foreach my $row ( @rows ) { >- push @values, map { >+ push @values, [ map { > my $col = $_; > ( @multiline and grep { $_ eq $col } @multiline ) > ? join "\r\n", @{$row->{$col}} # join multiline values > : $row->{$col}; >- } @columns; >+ } @columns ]; > } > return { query => $query, placeholders => $placeholders, values => \@values }; > } >@@ -509,8 +509,9 @@ sub load_sql { > my $placeholders = $query_info->{placeholders}; > my $values = $query_info->{values}; > # Doing only 1 INSERT query for the whole table >- $query .= join ', ', ( $placeholders ) x scalar @values; >- $dbh->do( $query, undef, @values ); >+ my @all_rows_values = map { @$_ } @$values; >+ $query .= join ', ', ( $placeholders ) x scalar @$values; >+ $dbh->do( $query, undef, @all_rows_values ); > } > for my $statement ( @{ $yaml->{'sql_statements'} } ) { # extra SQL statements > $dbh->do($statement); >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 24912
:
101078
|
101079
|
101080
|
101081
|
101295
|
101296