Skip to content

Fix: compare number field values numerically in search - #1361

Open
Rom1-B wants to merge 2 commits into
11.0/bugfixesfrom
support_47696
Open

Rom1-B wants to merge 2 commits into
11.0/bugfixesfrom
support_47696

Conversation

@Rom1-B

@Rom1-B Rom1-B commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Checklist before requesting a review

Please delete options that are not relevant.

  • I have performed a self-review of my code.
  • I have added tests (when available) that prove my fix is effective or that my feature works.
  • I have updated the CHANGELOG with a short functional description of the fix or new feature.
  • This change requires a documentation update.

Description

  • It fixes !47696
  • Searching a number field with is / is not returned nothing for values of 1000 or more, because values were cast to DECIMAL(10,7) which caps them at 999.9999999.
  • <, >, <= and >= compared values as text, so < 2000 excluded 999 but included 12345.
  • is not and negated criteria excluded items whose block was never saved.
  • Values are now compared numerically without precision limit (1000 equals 1000.0, comma accepted as decimal separator), negated criteria include items without value, a non numeric searched value matches nothing instead of raising a SQL warning, and is 0 matches items without value like core does.
User Warning: MySQL query warnings:
Warnings:
1264: Out of range value for column '(null)' at row 4
1264: Out of range value for column '(null)' at row 5

Screenshots (if appropriate):

@Rom1-B
Rom1-B force-pushed the support_47696 branch 2 times, most recently from 4da3346 to b786618 Compare November 18, 2026 10:15
@Rom1-B
Rom1-B requested review from a team, Herafia, Mary-Clb and jdurand-teclib and removed request for a team November 18, 2026 10:17

@jdurand-teclib jdurand-teclib left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

See review

Comment thread hook.php Outdated
$column = $DB->quoteName($table . '_' . $field) . '.' . $DB->quoteName($field);
$number_predicate = static function (string $operator, string $value) use ($DB, $column): string {
$value = str_replace(',', '.', trim($value));
if (!is_numeric($value) || abs((float) $value) >= 1e35) {

@jdurand-teclib jdurand-teclib Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The value filter doesn't seem to work.

I tried the following on your branch and got a 1264 SQL query warning:

  1. Create a tab block for computer
  2. Create a number field
  3. fill the field with 1e40 as value
  4. Make a search in computer list with the field < 2000
  5. Got a Warning
image image

It shouldn't happen, as you are filtering values above 1e35, but maybe we do not make that check ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

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.

3 participants