[Bug 24432] New: Request an endpoint with a date column in order by throws bad parameter exception
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24432 Bug ID: 24432 Summary: Request an endpoint with a date column in order by throws bad parameter exception Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: NEW Severity: blocker Priority: P5 - low Component: REST API Assignee: koha-bugs@lists.koha-community.org Reporter: agustinmoyano@theke.io CC: tomascohen@gmail.com Depends on: 23893 Blocks: 20936 When you request an endpoint in the API with a date as orderby, it throws Koha::Exceptions::BadParameter. Koha::REST::Plugin::Query in _build_order_atom, in order to get the model parameter for the order by, it requests {instance of Koha::Objects}->attributes_from_api({ <api parameter name> => 1 }); to get that hash translated, and use the resulting key as the model column to do the order by. This works ok for all datatypes except date types, because it's trying to transate the value of "1" as a date, throwig the mentioned exception. In my opinion, _build_order_atom should not use attributes_from_api, but should use the mapping in Koha::Object to get the column name. Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=20936 [Bug 20936] Holds History for patrons in OPAC https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23893 [Bug 23893] Add ->new_from_api and ->set_from_api methods to Koha::Object -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24432 Agustín Moyano <agustinmoyano@theke.io> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |agustinmoyano@theke.io |ity.org | -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24432 --- Comment #1 from Agustín Moyano <agustinmoyano@theke.io> --- Created attachment 97421 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=97421&action=edit Bug 24432: Regresion test To test: 1. apply this patch 2. prove t/Koha/REST/Plugin/Query.t Test should fail at this point. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24432 Agustín Moyano <agustinmoyano@theke.io> changed: What |Removed |Added ---------------------------------------------------------------------------- Patch complexity|--- |Small patch Status|NEW |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24432 Agustín Moyano <agustinmoyano@theke.io> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #97421|0 |1 is obsolete| | --- Comment #2 from Agustín Moyano <agustinmoyano@theke.io> --- Created attachment 97424 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=97424&action=edit Bug 24432: Regresion test To test: 1. apply this patch 2. prove t/Koha/REST/Plugin/Query.t Test should fail at this point. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24432 --- Comment #3 from Agustín Moyano <agustinmoyano@theke.io> --- Created attachment 97425 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=97425&action=edit Bug 24432: add Koha::Objects->from_api_mapping This patch adds from_api_mapping to Koha::Objects, in order to be able to get the mapping from a result set. To test: 1. apply this patch 2. prove t/db_dependent/Koha/Objects.t 3. sign off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24432 --- Comment #4 from Agustín Moyano <agustinmoyano@theke.io> --- Created attachment 97426 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=97426&action=edit Bug 24432: Use Koha::Objects->from_api_mapping instead of attributes_from_api to get the column name in Koha::REST::Plugins::Query->_build_order_atom Use the mapping instead of building a fake hash only to get the key name. To test: 1. apply this patch 2. prove t/Koha/REST/Plugin/Query.t 3. sign off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24432 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|Request an endpoint with a |order_by broken for date |date column in order by |columns |throws bad parameter | |exception | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24432 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |joonas.kylmala@helsinki.fi, | |josef.moravec@gmail.com, | |julian.maurice@biblibre.com | |, | |kyle@bywatersolutions.com, | |martin.renvoize@ptfs-europe | |.com --- Comment #5 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Great catch! -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24432 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24432 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #97424|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24432 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #97425|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24432 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #97426|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24432 --- Comment #6 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 97528 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=97528&action=edit Bug 24432: Regresion test To test: 1. apply this patch 2. prove t/Koha/REST/Plugin/Query.t Test should fail at this point. Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24432 --- Comment #7 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 97529 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=97529&action=edit Bug 24432: add Koha::Objects->from_api_mapping This patch adds from_api_mapping to Koha::Objects, in order to be able to get the mapping from a result set. To test: 1. apply this patch 2. prove t/db_dependent/Koha/Objects.t 3. sign off Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24432 --- Comment #8 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 97530 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=97530&action=edit Bug 24432: Use from_api_mapping to translate column name in _build_order_atom Use the mapping instead of building a fake hash only to get the key name. To test: 1. apply this patch 2. prove t/Koha/REST/Plugin/Query.t 3. sign off Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24432 Nick Clemens <nick@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Passed QA -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24432 Nick Clemens <nick@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #97528|0 |1 is obsolete| | Attachment #97529|0 |1 is obsolete| | Attachment #97530|0 |1 is obsolete| | --- Comment #9 from Nick Clemens <nick@bywatersolutions.com> --- Created attachment 97660 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=97660&action=edit Bug 24432: Regresion test To test: 1. apply this patch 2. prove t/Koha/REST/Plugin/Query.t Test should fail at this point. Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Nick Clemens <nick@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24432 --- Comment #10 from Nick Clemens <nick@bywatersolutions.com> --- Created attachment 97661 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=97661&action=edit Bug 24432: add Koha::Objects->from_api_mapping This patch adds from_api_mapping to Koha::Objects, in order to be able to get the mapping from a result set. To test: 1. apply this patch 2. prove t/db_dependent/Koha/Objects.t 3. sign off Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Nick Clemens <nick@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24432 --- Comment #11 from Nick Clemens <nick@bywatersolutions.com> --- Created attachment 97662 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=97662&action=edit Bug 24432: Use from_api_mapping to translate column name in _build_order_atom Use the mapping instead of building a fake hash only to get the key name. To test: 1. apply this patch 2. prove t/Koha/REST/Plugin/Query.t 3. sign off Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Nick Clemens <nick@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24432 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Passed QA |Pushed to master Version(s)| |20.05.00 released in| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24432 --- Comment #12 from Martin Renvoize <martin.renvoize@ptfs-europe.com> --- Nice work everyone! Pushed to master for 20.05 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24432 Joy Nelson <joy@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |FIXED CC| |joy@bywatersolutions.com Status|Pushed to master |RESOLVED --- Comment #13 from Joy Nelson <joy@bywatersolutions.com> --- does not apply to 19.11.x not backported -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24432 Agustín Moyano <agustinmoyano@theke.io> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks|20936 | Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=20936 [Bug 20936] Holds History for patrons in OPAC -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org