Skip to content

Conversation

@rameenaamir137
Copy link
Collaborator

Fix: Empty integer fields saved as 0 instead of NULL
Problem Description
When creating or editing classifications in ReLiS, empty integer fields (such as "Number of citations") were being saved as 0 in the database instead of NULL. This caused issues when editing classifications - fields that were intentionally left empty would show 0 instead of remaining empty.
Root Cause
The form processing logic in relis_app/models/DBConnection_mdl.php was only checking for empty date fields to send as NULL to stored procedures, but was not handling empty int or number fields properly. Empty integer fields were being sent as empty strings ('') which MariaDB/MySQL stored procedures automatically convert to 0.
Solution
Modified the form processing logic to check for empty integer fields and send them as NULL instead of empty strings.
Files Changed
relis_app/models/DBConnection_mdl.php - Modified form processing logic in save_reference_mdl() function
Testing
✅ Create a new classification with empty "Number of citations" field
✅ Save the classification - field should store NULL in database
✅ Edit the classification - field should remain empty instead of showing 0
✅ Verify that non-empty integer fields still work correctly
✅ Verify that other field types (text, date, etc.) are not affected
466824237-3057639c-1174-471b-bf6a-fb5d8511dcb4
466824240-2c9772b2-f2bb-4cf9-b59d-f315bf1a7810

…default values after editing the classification
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants