Bugzilla – Attachment 126669 Details for
Bug 28585
Cannot search on date fields
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28585: Use the datetime_parser for handling API dates
Bug-28585-Use-the-datetimeparser-for-handling-API-.patch (text/plain), 2.21 KB, created by
Martin Renvoize (ashimema)
on 2021-10-21 15:18:51 UTC
(
hide
)
Description:
Bug 28585: Use the datetime_parser for handling API dates
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2021-10-21 15:18:51 UTC
Size:
2.21 KB
patch
obsolete
>From b1415a6ed81780583cf738be4b7e5f33b6f4192c Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 25 Jun 2021 11:37:29 -0300 >Subject: [PATCH] Bug 28585: Use the datetime_parser for handling API dates > >This patchset takes the GET /patrons route as a sample usage for filtering >on date and date-time (including timestamp) fields. > >It then makes Koha::Object->attributes_from_api use the DB storage >datetime parser for format the parameters correctly. > >To test: > >1. Apply the regression tests >2. Run: > $ kshell > k$ prove t/db_dependent/api/v1/patrons.t >=> FAIL: It doesn't find the patron when filtering by date >3. Apply this patch >4. Repeat 2 >=> SUCCESS: It works now! >5. Sign off :-D > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >Signed-off-by: David Nind <david@davidnind.com> >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > Koha/Object.pm | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) > >diff --git a/Koha/Object.pm b/Koha/Object.pm >index c7ba4704f3..8daffd536f 100644 >--- a/Koha/Object.pm >+++ b/Koha/Object.pm >@@ -695,6 +695,7 @@ sub attributes_from_api { > > my $params; > my $columns_info = $self->_result->result_source->columns_info; >+ my $dtf = $self->_result->result_source->storage->datetime_parser; > > while (my ($key, $value) = each %{ $from_api_params } ) { > my $koha_field_name = >@@ -709,8 +710,14 @@ sub attributes_from_api { > } > elsif ( _date_or_datetime_column_type( $columns_info->{$koha_field_name}->{data_type} ) ) { > try { >- $value = dt_from_string($value, 'rfc3339') >- if defined $value; >+ if ( $columns_info->{$koha_field_name}->{data_type} eq 'date' ) { >+ $value = $dtf->format_date(dt_from_string($value, 'rfc3339')) >+ if defined $value; >+ } >+ else { >+ $value = $dtf->format_datetime(dt_from_string($value, 'rfc3339')) >+ if defined $value; >+ } > } > catch { > Koha::Exceptions::BadParameter->throw( parameter => $key ); >-- >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 28585
:
122381
|
122444
|
122445
|
122446
|
122457
|
122458
|
122459
|
123115
|
123116
|
123117
|
126668
| 126669 |
126670
|
126671
|
126679