Bugzilla – Attachment 101295 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: Add a new yml2sql sub to C4::Installer
Bug-24912-Add-a-new-yml2sql-sub-to-C4Installer.patch (text/plain), 1.38 KB, created by
Jonathan Druart
on 2020-03-20 15:29:09 UTC
(
hide
)
Description:
Bug 24912: Add a new yml2sql sub to C4::Installer
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2020-03-20 15:29:09 UTC
Size:
1.38 KB
patch
obsolete
>From 02ee6f823a75e28f24a943fa97c18f9fbf37772e Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 19 Mar 2020 12:33:47 +0100 >Subject: [PATCH] Bug 24912: Add a new yml2sql sub to C4::Installer > >It will allow us to generate sql code from the yml files >--- > C4/Installer.pm | 22 ++++++++++++++++++++++ > 1 file changed, 22 insertions(+) > >diff --git a/C4/Installer.pm b/C4/Installer.pm >index b9a0ce53b2..8854cf83df 100644 >--- a/C4/Installer.pm >+++ b/C4/Installer.pm >@@ -480,6 +480,28 @@ sub process_yml_table { > return { query => $query, placeholders => $placeholders, values => \@values }; > } > >+sub yml2sql { >+ my ( $class, $filepath ) = @_; >+ my $dbh = C4::Context->dbh; >+ my $yaml = LoadFile( $filepath ); >+ my @queries; >+ for my $table ( @{ $yaml->{'tables'} } ) { >+ my $query_info = process_yml_table($table); >+ my $query = $query_info->{query}; >+ my $values = $query_info->{values}; >+ push @queries, $query . "\n" . join( >+ ",\n", >+ map { >+ '(' . join( ', ', map { $dbh->quote($_) } @$_ ) . ')' >+ } @$values >+ ); >+ } >+ for my $statement ( @{ $yaml->{'sql_statements'} } ) { >+ push @queries, $statement; >+ } >+ return join ";\n", @queries; >+} >+ > sub load_sql { > my $self = shift; > my $filename = shift; >-- >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