[Bug] can't order by concat (fix suggested)

[Bug] can't order by concat (fix suggested)

srushasrusha Posts: 5Questions: 2Answers: 0

Today, one can't use concat in serverside ordering using Editor instance. For example:
Field::inst( 'CONCAT(orders.first_name," ", orders.last_name)', 'name'), would result in an error when ordering by this field.

This reason for this is that function order ( $order ) in Query.php uses explode to separate between differing identifiers.
The CONCAT commas confuse this function which results in an error.

the explode line should be replaced by
$order = preg_split('/\,(?![^(]*))/',$order);
to ignore in parenthesis commas.

Answers

  • allanallan Posts: 61,726Questions: 1Answers: 10,109 Site admin

    Nice one - thanks for this and letting me know about that problem. Fix committed here.

    Allan

This discussion has been closed.