[Bug 29157] New: REST API - cannot update patron & leave date_of_birth null
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29157 Bug ID: 29157 Summary: REST API - cannot update patron & leave date_of_birth null Change sponsored?: --- Product: Koha Version: 21.05 Hardware: All OS: All Status: NEW Severity: normal Priority: P5 - low Component: REST API Assignee: koha-bugs@lists.koha-community.org Reporter: ephetteplace@cca.edu Created attachment 125644 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=125644&action=edit diff of patron record after REST PUT action I noticed when trying to update patrons with a Python script that Koha set everyone's birthday to the current date. For each patron, I sent a Python dict where patron['date_of_birth'] was None (Python's null value). I can send an ISO 8601 date and DOB updates appropriately but I cannot find a way to leave the date empty, which is desirable (we don't care about age). Here's what I tried: date_of_birth = '' (empty string) date_of_birth = "null" date_of_birth = "undef" All these receive the same formatting error response: 400 Response {'errors': [{'message': '/anyOf/0 Does not match date format.', 'path': '/body/date_of_birth'}], 'status': 400} As I said, setting birthdate to None (which translates to `null` in JSON) updates the DOB to the current date, which I don't think makes sense since it's a nullable field in the database. I'll attach a diff of a minimal test patron where I added a "1" to their cardnumber and did nothing else. The steps were: - create a minimal patron record (e.g. with email, userid, names) - HTTP GET $API/patrons/username=$USERNAME (I did not test HTTP GET $API/patrons/$BORROWERNUMBER but I assume it works the same) - update cardnumber e.g. patron['cardnumber'] = patron['cardnumber'] + 1 - PUT $API/patrons/$BORROWERNUMBER with json=patron A few fields other than cardnumber changed. Both last_seen and updated_on make sense, I find it odd date_renewed was set to the current date since I was not renewing the patron but that's at least not problematic in our use case. It's the DOB I'd like to avoid updating, though. Let me know if I can provide more example data. -- 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=29157 --- Comment #1 from Eric Phetteplace <ephetteplace@cca.edu> --- Small update to this - looks like DOB is not one of the fields that can be bulk updated with /cgi-bin/koha/tools/modborrowers.pl either so that makes the problem more annoying. We can't bulk update a bunch of users and then erase all the DOB data afterwards. I know ByWater could run a SQL query for us but it just adds one extra step. -- 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=29157 Katrin Fischer <katrin.fischer@bsz-bw.de> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |tomascohen@gmail.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29157 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Version|21.05 |master Assignee|koha-bugs@lists.koha-commun |tomascohen@gmail.com |ity.org | Status|NEW |ASSIGNED --- Comment #2 from Tomás Cohen Arazi <tomascohen@gmail.com> --- I confirm the bug exists. Will take a look tomorrow. It affect date/date-time attributes. -- 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=29157 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|REST API - cannot update |Cannot set date/date-time |patron & leave |attributes to NULL |date_of_birth null | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29157 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |Needs Signoff CC| |jonathan.druart+koha@gmail. | |com, | |kyle@bywatersolutions.com, | |martin.renvoize@ptfs-europe | |.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29157 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |katrin.fischer@bsz-bw.de -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29157 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #125644|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=29157 --- Comment #3 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 125909 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=125909&action=edit Bug 29157: Regression tests 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=29157 --- Comment #4 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 125910 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=125910&action=edit Bug 29157: Date and Datetime attributes cannot be set NULL 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=29157 Jonathan Druart <jonathan.druart+koha@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=28585 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29157 David Nind <david@davidnind.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=29157 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #125909|0 |1 is obsolete| | --- Comment #5 from David Nind <david@davidnind.com> --- Created attachment 125994 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=125994&action=edit Bug 29157: Regression tests Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29157 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #125910|0 |1 is obsolete| | --- Comment #6 from David Nind <david@davidnind.com> --- Created attachment 125995 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=125995&action=edit Bug 29157: Date and Datetime attributes cannot be set NULL Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29157 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |david@davidnind.com --- Comment #7 from David Nind <david@davidnind.com> --- Tested by: 1. Applying regression tests patch 2. Run tests - these should fail: prove t/db_dependent/api/v1/patrons.t 3. Apply second patch 4. Run tests again - they should now pass 5. Sign-off! Hope that is sufficient. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29157 --- Comment #8 from Tomás Cohen Arazi <tomascohen@gmail.com> --- (In reply to David Nind from comment #7)
Tested by:
1. Applying regression tests patch 2. Run tests - these should fail: prove t/db_dependent/api/v1/patrons.t 3. Apply second patch 4. Run tests again - they should now pass 5. Sign-off!
Hope that is sufficient.
Thanks, I forgot to add *exactly* that! -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29157 Joonas Kylmälä <joonas.kylmala@iki.fi> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Failed QA CC| |joonas.kylmala@iki.fi --- Comment #9 from Joonas Kylmälä <joonas.kylmala@iki.fi> --- The unit test is in the wrong place, it should test the attributes_from_api function directly, please add it to t/db_dependent/Koha/Object.t. Otherwise the fix looks good. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29157 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Failed QA |ASSIGNED --- Comment #10 from Tomás Cohen Arazi <tomascohen@gmail.com> --- (In reply to Joonas Kylmälä from comment #9)
The unit test is in the wrong place, it should test the attributes_from_api function directly, please add it to t/db_dependent/Koha/Object.t. Otherwise the fix looks good.
Fair enough. I will of course leave the tests I added first, so we can track breaking this in another place of the stack. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29157 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29157 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #125994|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=29157 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #125995|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=29157 --- Comment #11 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 126128 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=126128&action=edit Bug 29157: Regression tests This patch implements regression tests for the filed bug. Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29157 --- Comment #12 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 126129 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=126129&action=edit Bug 29157: Date and Datetime attributes cannot be set NULL This patch makes Koha::Object->attribute_from_api allow setting attributes the undef value. The original implementation passed the value directly to dt_from_string, which made the attribute be set the current date. To test: 1. Apply the regression tests patch 2. Run: $ kshell k$ prove t/db_dependent/Koha/Object.t \ t/db_dependent/api/v1/patrons.t => FAIL: Tests fail! Our code is buggy! 3. Apply this patch 4. Repeat 2 => SUCCESS! Fix fixed this thing! 5. Sign off :-D Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29157 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=29157 Eric Phetteplace <ephetteplace@cca.edu> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #126128|0 |1 is obsolete| | --- Comment #13 from Eric Phetteplace <ephetteplace@cca.edu> --- Created attachment 126220 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=126220&action=edit Bug 29157: Regression tests I don't think this needs a third sign-off but I wanted to give it a try. Looks good! Thanks for getting to this so quickly! -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29157 Eric Phetteplace <ephetteplace@cca.edu> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #126129|0 |1 is obsolete| | --- Comment #14 from Eric Phetteplace <ephetteplace@cca.edu> --- Created attachment 126221 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=126221&action=edit Bug 29157: Date and Datetime attributes cannot be set NULL Signing off on the other patch. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29157 Joonas Kylmälä <joonas.kylmala@iki.fi> changed: What |Removed |Added ---------------------------------------------------------------------------- QA Contact| |joonas.kylmala@iki.fi -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29157 Joonas Kylmälä <joonas.kylmala@iki.fi> 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=29157 Joonas Kylmälä <joonas.kylmala@iki.fi> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #126220|0 |1 is obsolete| | Attachment #126221|0 |1 is obsolete| | --- Comment #15 from Joonas Kylmälä <joonas.kylmala@iki.fi> --- Created attachment 126237 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=126237&action=edit Bug 29157: Regression tests This patch implements regression tests for the filed bug. Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Eric Phetteplace <phette23@gmail.com> Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29157 --- Comment #16 from Joonas Kylmälä <joonas.kylmala@iki.fi> --- Created attachment 126238 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=126238&action=edit Bug 29157: Date and Datetime attributes cannot be set NULL This patch makes Koha::Object->attribute_from_api allow setting attributes the undef value. The original implementation passed the value directly to dt_from_string, which made the attribute be set the current date. To test: 1. Apply the regression tests patch 2. Run: $ kshell k$ prove t/db_dependent/Koha/Object.t \ t/db_dependent/api/v1/patrons.t => FAIL: Tests fail! Our code is buggy! 3. Apply this patch 4. Repeat 2 => SUCCESS! Fix fixed this thing! 5. Sign off :-D Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Eric Phetteplace <phette23@gmail.com> Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29157 Jonathan Druart <jonathan.druart+koha@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Version(s)| |21.11.00 released in| | Status|Passed QA |Pushed to master -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29157 --- Comment #17 from Jonathan Druart <jonathan.druart+koha@gmail.com> --- Pushed to master for 21.11, thanks to everybody involved! -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29157 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Pushed to master |Pushed to stable Version(s)|21.11.00 |21.11.00,21.05.05 released in| | --- Comment #18 from Kyle M Hall <kyle@bywatersolutions.com> --- Pushed to 21.05.x for 21.05.05 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29157 Fridolin Somers <fridolin.somers@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |fridolin.somers@biblibre.co | |m Status|Pushed to stable |Pushed to oldstable Version(s)|21.11.00,21.05.05 |21.11.00,21.05.05,20.11.11 released in| | --- Comment #19 from Fridolin Somers <fridolin.somers@biblibre.com> --- Pushed to 20.11.x for 20.11.11 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29157 Victor Grousset/tuxayo <victor@tuxayo.net> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |victor@tuxayo.net Status|Pushed to oldstable |RESOLVED Resolution|--- |FIXED --- Comment #20 from Victor Grousset/tuxayo <victor@tuxayo.net> --- Not backported to oldoldstable (20.05.x). Feel free to ask if it's needed. -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org