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

Created on 9 May 2014, over 10 years ago
Updated 1 August 2023, over 1 year 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 2 days 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.71.5 2024