Bugzilla – Attachment 44264 Details for
Bug 14627
GetAuthorisedValueByCode does not handle undef intelligently
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[SIGNED-OFF] Bug 14627: Improve SQL query
SIGNED-OFF-Bug-14627-Improve-SQL-query.patch (text/plain), 1.28 KB, created by
Bernardo Gonzalez Kriegel
on 2015-10-31 00:22:28 UTC
(
hide
)
Description:
[SIGNED-OFF] Bug 14627: Improve SQL query
Filename:
MIME Type:
Creator:
Bernardo Gonzalez Kriegel
Created:
2015-10-31 00:22:28 UTC
Size:
1.28 KB
patch
obsolete
>From 55883caf3f08c87ef2a5aa64c920e27eb7d86803 Mon Sep 17 00:00:00 2001 >From: Mark Tompsett <mtompset@hotmail.com> >Date: Sun, 4 Oct 2015 03:13:26 -0400 >Subject: [PATCH] [SIGNED-OFF] Bug 14627: Improve SQL query > >A field=NULL condition does not run properly. If category is >undefined, then don't include it in the query. > >Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> >No regressions detected, no errors >--- > C4/Koha.pm | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) > >diff --git a/C4/Koha.pm b/C4/Koha.pm >index 052147e..115152e 100644 >--- a/C4/Koha.pm >+++ b/C4/Koha.pm >@@ -1342,9 +1342,16 @@ sub GetAuthorisedValueByCode { > } > > my $field = $opac ? 'lib_opac' : 'lib'; >+ my @params; > my $dbh = C4::Context->dbh; >- my $sth = $dbh->prepare("SELECT $field FROM authorised_values WHERE category=? AND authorised_value =?"); >- $sth->execute( $category, $authvalcode ); >+ my $sql = "SELECT $field FROM authorised_values WHERE authorised_value =?"; >+ push @params, $authvalcode; >+ if (defined $category) { >+ $sql .= ' AND category=?'; >+ push @params, $category; >+ } >+ my $sth = $dbh->prepare($sql); >+ $sth->execute( @params ); > while ( my $data = $sth->fetchrow_hashref ) { > return $data->{ $field }; > } >-- >1.9.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 14627
:
41266
|
43090
|
43091
|
44263
| 44264