Skip to content

Commit

Permalink
test match driver
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBnl committed Nov 10, 2024
1 parent e079b26 commit eab8019
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Taxonomies/TermQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Database\Query\Expression;
use Illuminate\Database\Query\JoinClause;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
use Statamic\Contracts\Taxonomies\Term as TermContract;
use Statamic\Eloquent\Entries\EntryModel;
Expand Down Expand Up @@ -232,7 +233,12 @@ private function applyCollectionAndTaxonomyWheres()
->join($enrtiesTable, function (JoinClause $join) use ($taxonomy, $enrtiesTable, $termsTable) {
// TODO: make Expression db driver independent
$wrappedColumn = $join->getGrammar()->wrap("{$termsTable}.slug");
$columnExpression = new Expression("json_quote({$wrappedColumn})");
$column = match (DB::getDriverName()) {
'mysql' => "json_quote({$wrappedColumn})",
default => $wrappedColumn,
};

$columnExpression = new Expression($column);
$join->on("{$enrtiesTable}.collection", '=', "{$enrtiesTable}.collection")
->whereIn("{$enrtiesTable}.collection", $this->collections)
->whereJsonContains("{$enrtiesTable}.data->{$taxonomy}", $columnExpression);
Expand Down

0 comments on commit eab8019

Please sign in to comment.