Bugzilla – Attachment 101011 Details for
Bug 24883
Add `misc/load_yaml.pl` utility script to allow manual loading of yaml data files
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24883: Move to a flat array with all values to an array of arrayref
Bug-24883-Move-to-a-flat-array-with-all-values-to-.patch (text/plain), 2.17 KB, created by
Jonathan Druart
on 2020-03-19 12:24:42 UTC
(
hide
)
Description:
Bug 24883: Move to a flat array with all values to an array of arrayref
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2020-03-19 12:24:42 UTC
Size:
2.17 KB
patch
obsolete
>From c62d71e0421d25d4ca6a626ddfdf7dabcdeb14f6 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 24883: 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 24883
:
100831
|
101009
|
101010
|
101011
|
101012
|
101013
|
101292
|
101293
|
101294
|
101332
|
101333
|
101901
|
101902
|
101903
|
101904
|
101905
|
101950
|
101951
|
101952
|
101953
|
101954