Bugzilla – Attachment 79193 Details for
Bug 21281
Label Template - Creation not working
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21281: Correct t/db_dependent/Creators/Lib.t failures
Bug-21281-Correct-tdbdependentCreatorsLibt-failure.patch (text/plain), 3.25 KB, created by
Marcel de Rooy
on 2018-09-21 08:31:43 UTC
(
hide
)
Description:
Bug 21281: Correct t/db_dependent/Creators/Lib.t failures
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2018-09-21 08:31:43 UTC
Size:
3.25 KB
patch
obsolete
>From e00f74c5a4da96035b8d5928eb331c69c1acaab1 Mon Sep 17 00:00:00 2001 >From: Mark Tompsett <mtompset@hotmail.com> >Date: Wed, 5 Sep 2018 18:41:32 +0000 >Subject: [PATCH] Bug 21281: Correct t/db_dependent/Creators/Lib.t failures >Content-Type: text/plain; charset=utf-8 > >TEST PLAN >--------- >1) apply first patch >2) kshell kohadev >3) prove -r -v t/db_dependent/Creators/ > -- failures >4) apply this patch >5) repeat 2,3 > -- no failures >6) run koha qa test tools > >Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > C4/Creators/Lib.pm | 21 +++++++++++++++++---- > t/db_dependent/Creators/Lib.t | 2 +- > 2 files changed, 18 insertions(+), 5 deletions(-) > >diff --git a/C4/Creators/Lib.pm b/C4/Creators/Lib.pm >index 46ae21a..f5616a5 100644 >--- a/C4/Creators/Lib.pm >+++ b/C4/Creators/Lib.pm >@@ -67,7 +67,11 @@ C4::Creators::Lib > > sub _SELECT { > my @params = @_; >- my $query = "SELECT `$params[0]` FROM $params[1]"; >+ my $fields_list = $params[0]; >+ if (index($fields_list, ' ')==-1 && index($fields_list,',')==-1 && $fields_list ne '*') { >+ $fields_list = "`$fields_list`"; >+ } >+ my $query = "SELECT $fields_list FROM $params[1]"; > $params[2] ? $query .= " WHERE $params[2];" : $query .= ';'; > my $sth = C4::Context->dbh->prepare($query); > # $sth->{'TraceLevel'} = 3; >@@ -145,16 +149,25 @@ my $output_formats = [ > sub _build_query { > my ( $params, $table ) = @_; > my @fields = exists $params->{fields} ? @{ $params->{fields} } : (); >- my $query = "SELECT " . ( @fields ? join(', ', map {"`$_`"} @fields ) : '*' ) . " FROM $table"; >+ my @fields2 = (); >+ foreach my $field_name (@fields) { >+ if (index($field_name,' ')==-1 && $field_name ne '*') { >+ push @fields2, "`$field_name`"; >+ } else { >+ push @fields2, $field_name; >+ } >+ } >+ @fields = @fields2; >+ my $query = "SELECT " . ( @fields ? join(', ', @fields ) : '*' ) . " FROM $table"; > my @where_args; > if ( exists $params->{filters} ) { > $query .= ' WHERE 1 '; > while ( my ( $field, $values ) = each %{ $params->{filters} } ) { > if ( ref( $values ) ) { >- $query .= " AND $field IN ( " . ( ('?,') x (@$values-1) ) . "? ) "; # a comma separates elements in a list... >+ $query .= " AND `$field` IN ( " . ( ('?,') x (@$values-1) ) . "? ) "; # a comma separates elements in a list... > push @where_args, @$values; > } else { >- $query .= " AND $field = ? "; >+ $query .= " AND `$field` = ? "; > push @where_args, $values; > } > } >diff --git a/t/db_dependent/Creators/Lib.t b/t/db_dependent/Creators/Lib.t >index 7a981de..d180850 100644 >--- a/t/db_dependent/Creators/Lib.t >+++ b/t/db_dependent/Creators/Lib.t >@@ -398,7 +398,7 @@ is( $templates->[0]->{creator}, 'Labels', 'creator is good > $templates = get_all_templates( { filters => { rows => [-42, 7]} } ); > is( @$templates, $count, 'There is 1 template matching' ); > # With orderby param ------------------ >-$templates = get_all_templates( { orderby => 'rows DESC' } ); >+$templates = get_all_templates( { orderby => '`rows` DESC' } ); > > $query = ' > SELECT count(*) >-- >2.1.4
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 21281
:
78292
|
78448
|
78449
|
78668
|
78669
|
79192
| 79193 |
79194