Bugzilla – Attachment 171652 Details for
Bug 37902
Timezone ignored when passing rfc3339 formatted date (search 'q')
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37902: Apply exact match for datetime
Bug-37902-Apply-exact-match-for-datetime.patch (text/plain), 2.30 KB, created by
Jonathan Druart
on 2024-09-18 08:04:51 UTC
(
hide
)
Description:
Bug 37902: Apply exact match for datetime
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2024-09-18 08:04:51 UTC
Size:
2.30 KB
patch
obsolete
>From 9aa24a4d2d9f53edfeef34d9935f244d0cac9727 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 18 Sep 2024 09:49:50 +0200 >Subject: [PATCH] Bug 37902: Apply exact match for datetime > >We do not want to apply "like" and do a "contains" search if a correctly >formatted date is passed (ie. starting with "YYYY-MM-DD HH:MM:SS") > >It causes underlying problems if we add '%' characters to this string as >it will then become an invalid date. > >There are several ways of dealing with this problem. This patch is >suggesting the easiest path: Apply an exact search (ie. do not add '%') >if the value appears to be a datetime. > >Certainly not the best looking patch but it seems to be quite effective: > * no need to change the client > * no need to rework build_query_params, merge_q_params, attributes_from_api > >We could (to confirm) pass the result set, but it seems a lot of additional processing >(that is done later already, in attributes_from_api) >--- > Koha/REST/Plugin/Query.pm | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > >diff --git a/Koha/REST/Plugin/Query.pm b/Koha/REST/Plugin/Query.pm >index c8ba09e8d49..fe3d936df97 100644 >--- a/Koha/REST/Plugin/Query.pm >+++ b/Koha/REST/Plugin/Query.pm >@@ -195,7 +195,10 @@ is raised. > my $match = $reserved_params->{_match} // 'contains'; > > foreach my $param ( keys %{$filtered_params} ) { >- if ( $match eq 'contains' ) { >+ if ( $match eq 'exact' || $filtered_params->{$param} =~ m[^\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}]) { >+ $params->{$param} = $filtered_params->{$param}; >+ } >+ elsif ( $match eq 'contains' ) { > $params->{$param} = > { like => '%' . $filtered_params->{$param} . '%' }; > } >@@ -205,9 +208,6 @@ is raised. > elsif ( $match eq 'ends_with' ) { > $params->{$param} = { like => '%' . $filtered_params->{$param} }; > } >- elsif ( $match eq 'exact' ) { >- $params->{$param} = $filtered_params->{$param}; >- } > else { > # We should never reach here, because the OpenAPI plugin should > # prevent invalid params to be passed >-- >2.34.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 37902
:
171389
|
171390
|
171391
|
171392
|
171402
|
171403
|
171515
|
171551
|
171652
|
171762
|
171763
|
171764
|
171765
|
171766
|
171767
|
171768
|
172105
|
172106
|
172107
|
172108
|
172109
|
172110
|
172111
|
172112