Does PHP max() correctly replicate SQL GREATEST() for non-numeric values?

Created on 9 May 2014, about 10 years ago
Updated 1 August 2023, 11 months ago

Follow-up to #2259947: Minor bug fixes in database system β†’ .

In Drupal\Core\Database\Driver\sqlite\Connection::sqlFunctionGreatest() we are trying to replicate the behavior of SQL GREATEST() using max(). This is supposed to work not just for numeric values, but also for strings, and maybe date/time?

The following is or will be fixed as part of #2259947: Minor bug fixes in database system β†’ :
- If one of the values is NULL, then the result is NULL.
- If no values are given, the result is NULL.

But this is not the end of the story. We need to test this with strings and other types, and we should write tests to verify the behavior.
We also need to check whether different SQL implementations (MySQL, other) are even consistent about the behavior of GREATEST().

I hope that we can find some external resources. It is unlikely that we are the first who deal with this problem.

πŸ“Œ Task
Status

Closed: duplicate

Version

11.0 πŸ”₯

Component
DatabaseΒ  β†’

Last updated about 11 hours ago

  • Maintained by
  • πŸ‡³πŸ‡±Netherlands @daffie
Created by

πŸ‡©πŸ‡ͺGermany donquixote

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024