[eluser]OverZealous[/eluser]
I'm worried about upgrading to CI 1.7.1 due to the changes with the ActiveRecord class.
It has been bad enough trying to get _protect_identifiers to not break everything, but now the
order_by method splits the input by commas blindly! I understand on the
from method, because tables shouldn't have functions, but
order_by?
A simple example: I have two numeric fields that may be NULL, cost and revenue. Now, if I want to order by profit (which is the difference between them), I have to use coalesce (a standard SQL function) to convert NULLs to 0.
My order by looks like this:
Code:
$this->db->order_by('(coalesce(revenue, 0) - coalesce(cost, 0))');
This worked on 1.7.0 after I included the updated _protect_identifiers that stopped being so darn helpful if the field included open parentheses.
Now, however, order_by is going to convert this completely valid line into this:
Code:
// ends up something like:
ORDER BY (coalesce(revenue, 0) - coalesce(cost, "0))"
If ActiveRecord's order_by MUST process these items, it needs to have the same strategy as _protect_identifiers. If the field contains open parentheses, just don't split it.
Why can't the CI team just let some things be?
Frustrated,