Skip to content

Commit

Permalink
Merge pull request #9157 from kenjis/refactor-BaseBuilder
Browse files Browse the repository at this point in the history
refactor: BaseBuilder
  • Loading branch information
kenjis authored Aug 30, 2024
2 parents 77f5e47 + 9e97a0c commit c326cd1
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions system/Database/BaseBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -3164,21 +3164,27 @@ protected function compileWhereHaving(string $qbKey): string
);

foreach ($conditions as &$condition) {
if (($op = $this->getOperator($condition)) === false
|| ! preg_match('/^(\(?)(.*)(' . preg_quote($op, '/') . ')\s*(.*(?<!\)))?(\)?)$/i', $condition, $matches)
$op = $this->getOperator($condition);
if (
$op === false
|| ! preg_match(
'/^(\(?)(.*)(' . preg_quote($op, '/') . ')\s*(.*(?<!\)))?(\)?)$/i',
$condition,
$matches
)
) {
continue;
}
// $matches = array(
// 0 => '(test <= foo)', /* the whole thing */
// 1 => '(', /* optional */
// 2 => 'test', /* the field name */
// 3 => ' <= ', /* $op */
// 4 => 'foo', /* optional, if $op is e.g. 'IS NULL' */
// 5 => ')' /* optional */
// );

if (isset($matches[4]) && $matches[4] !== '' && $matches[4] !== '0') {
// $matches = [
// 0 => '(test <= foo)', /* the whole thing */
// 1 => '(', /* optional */
// 2 => 'test', /* the field name */
// 3 => ' <= ', /* $op */
// 4 => 'foo', /* optional, if $op is e.g. 'IS NULL' */
// 5 => ')' /* optional */
// ];

if (isset($matches[4]) && $matches[4] !== '') {
$protectIdentifiers = false;
if (str_contains($matches[4], '.')) {
$protectIdentifiers = true;
Expand Down

0 comments on commit c326cd1

Please sign in to comment.