Skip to content

Commit 5ca984e

Browse files
committed
Fixed behaviour when filtering for null and not null
1 parent b688f43 commit 5ca984e

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

src/Parser.php

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -569,11 +569,25 @@ protected function parseFilter($filterParams)
569569

570570
if(!isset($keyMatches[3]))
571571
{
572-
$comparator = '=';
572+
if(strtolower(trim($filterParamValue)) == 'null')
573+
{
574+
$comparator = 'NULL';
575+
}
576+
else
577+
{
578+
$comparator = '=';
579+
}
573580
}
574581
else
575582
{
576-
$comparator = $supportedPostfixes[$keyMatches[3]];
583+
if(strtolower(trim($filterParamValue)) == 'null')
584+
{
585+
$comparator = 'NOT NULL';
586+
}
587+
else
588+
{
589+
$comparator = $supportedPostfixes[$keyMatches[3]];
590+
}
577591
}
578592

579593
$column = $keyMatches[2];
@@ -618,9 +632,19 @@ protected function parseFilter($filterParams)
618632
{
619633
$value = $values[0];
620634

621-
if($comparator == 'LIKE' || $comparator == 'NOT LIKE') $value = preg_replace('/(^\*|\*$)/', '%', $value);
635+
if($comparator == 'LIKE' || $comparator == 'NOT LIKE')
636+
{
637+
$value = preg_replace('/(^\*|\*$)/', '%', $value);
638+
}
622639

623-
$this->query->where($column, $comparator, $value);
640+
if($comparator == 'NULL' || $comparator == 'NOT NULL')
641+
{
642+
$this->query->whereNull($column, 'and', $comparator == 'NOT NULL');
643+
}
644+
else
645+
{
646+
$this->query->where($column, $comparator, $value);
647+
}
624648
}
625649
}
626650
}

0 commit comments

Comments
 (0)