Skip to content

Allow nullable integers and floats in imports#250

Merged
lat9 merged 2 commits intolat9:masterfrom
hucario:patch-1
Apr 10, 2026
Merged

Allow nullable integers and floats in imports#250
lat9 merged 2 commits intolat9:masterfrom
hucario:patch-1

Conversation

@hucario
Copy link
Copy Markdown
Contributor

@hucario hucario commented Mar 29, 2026

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.)

Copy link
Copy Markdown
Owner

@lat9 lat9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch on those, just a couple of changes requested.

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') {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@hucario
Copy link
Copy Markdown
Contributor Author

hucario commented Apr 9, 2026

Just in case you don't receive notifications for code review comments, I believe the code is OK as-is because nullable is set to a boolean on line 1706 and thus a boolean check is appropriate.

@lat9 lat9 merged commit 7106bcf into lat9:master Apr 10, 2026
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