feat: Resolution of bug Values of some categories are altered to the …#196
Open
rameenaamir137 wants to merge 3 commits intomainfrom
Open
feat: Resolution of bug Values of some categories are altered to the …#196rameenaamir137 wants to merge 3 commits intomainfrom
rameenaamir137 wants to merge 3 commits intomainfrom
Conversation
…default values after editing the classification
Collaborator
|
Hello @rameenaamir137, you can update this branch with the current main; it should fix the GitHub Action build issue. Cheers! |
| (isset($value['input_type']) && $value['input_type'] == 'date' && empty($val)) || | ||
| (isset($value['field_type']) && in_array($value['field_type'], ['int', 'number']) && empty($val)) | ||
| ) { | ||
| return "NULL"; |
Collaborator
There was a problem hiding this comment.
curious why can't we use return NULL instead of return "NULL" it will be consistent with php null right?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Screenshots

