Re: [RFC] Comparison and conversion inconsistency - need more info
| From: | Sanford Whiteman | Date: | Sun, 10 Nov 2013 09:20:57 +0000 |
| Subject: | Re: [RFC] Comparison and conversion inconsistency - need more info | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-70077@lists.php.net to get a copy of this message | ||
> I think almost all users are not expecting
> min(-10000, -1000, -100, NULL, 100, 1000) returns NULL.
I expect it.
Because, in fact, PHP is not SQL.
It is PHP, and it has its own rules that everybody plays by. They
aren't SQL rules (where NULLs may either be disregarded, as in
aggregates, or quite heavily regarded).
The ecosystem of PHP and SQL is, however, one of the fundamental
reasons you *must not* make the change you propose. SQL MIN() works
across one column within a rowset, while users often desire a similar
function that works across columns in a row. As they are unable to do
this in pure SQL, they will turn to application code, performing a PHP
min() across columns returned from SQL -- columns that quite commonly
contain PHP NULL if the DB layer supports it. All this time, they have
been getting NULL. You want them to get -10000 for those same rows and
not have that affect their application in a big way. Just... no.
> Besides, the manual is not explaining this weird behavior at all.
Sure it is.
-- S.