Allow nullable integers and floats in imports#250
Merged
lat9 merged 2 commits intolat9:masterfrom Apr 10, 2026
Merged
Conversation
lat9
requested changes
Apr 7, 2026
Owner
lat9
left a comment
There was a problem hiding this comment.
Good catch on those, just a couple of changes requested.
lat9
requested changes
Apr 9, 2026
| foreach ($table_fields as $field_name => $field_info) { | ||
| if ($this->tables[$table_name]['fields'][$field_name]['nullable'] && ($field_info['value'] == 'null' || $field_info['value'] == 'NULL')) { | ||
| $field_value = 'null'; | ||
| if ($this->tables[$table_name]['fields'][$field_name]['nullable'] && strtolower($field_info['value'] ?? 'null') === 'null') { |
Owner
There was a problem hiding this comment.
The 'nullable' field is a string, either 'N' or 'Y', so it will always "pass" the first clause of the conditional.
Same comment on line 1443.
Contributor
Author
|
Just in case you don't receive notifications for code review comments, I believe the code is OK as-is because |
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.
Unless I'm doing something wrong in writing my custom handler (which is entirely possible), I don't think it's currently possible to have nullable integers and floats due to importBuildSqlQuery casting to int and float without checking that they're not null. This changes that by adding a check that the field is nullable and is equal to null before performing any of the sanitization logic.
(The diff appears to be mangled due to indenting the existing sanitization code in an else block - the meaningful portion of the commit is three lines, duplicated for the insert logic.)