diff --git a/src/Sieve.php b/src/Sieve.php index 36ac48e..136b099 100644 --- a/src/Sieve.php +++ b/src/Sieve.php @@ -81,12 +81,12 @@ public function apply($queryBuilder) } if ($this->getSort() == "$property:asc_nulls_last") { - $queryBuilder->orderByRaw("ISNULL(\"$column\") asc") + $queryBuilder->orderByRaw("ISNULL($column) asc") ->orderBy($column, 'asc'); } if ($this->getSort() == "$property:desc_nulls_first") { - $queryBuilder->orderByRaw("ISNULL(\"$column\") desc") + $queryBuilder->orderByRaw("ISNULL($column) desc") ->orderBy($column, 'desc'); } } diff --git a/tests/SieveTest.php b/tests/SieveTest.php index 6026b06..6e7f5b5 100644 --- a/tests/SieveTest.php +++ b/tests/SieveTest.php @@ -93,7 +93,7 @@ public function applies_sieve_sorts_to_a_query_builder_asc_nulls_last() $seive->apply($builder); $this->assertEquals( - 'select * from "pets" order by ISNULL("name") asc, "name" asc', + 'select * from "pets" order by ISNULL(name) asc, "name" asc', $builder->toSql() ); } @@ -117,7 +117,7 @@ public function applies_sieve_sorts_to_a_query_builder_desc_nulls_first() $seive->apply($builder); $this->assertEquals( - 'select * from "pets" order by ISNULL("name") desc, "name" desc', + 'select * from "pets" order by ISNULL(name) desc, "name" desc', $builder->toSql() ); }