fix: fix CSM-005

This commit is contained in:
2026-05-08 20:09:02 +02:00
parent 9944b70ab1
commit 291dff697c
7 changed files with 665 additions and 344 deletions

View File

@@ -212,12 +212,17 @@ defmodule BDS.Scripting.Capabilities.Crud do
%Tag{name: tag_name} ->
Repo.all(
from(post in Post,
where: post.project_id == ^project_id,
order_by: [asc: post.created_at]
where:
post.project_id == ^project_id and
fragment(
"EXISTS (SELECT 1 FROM json_each(?) WHERE value = ?)",
post.tags,
^tag_name
),
order_by: [asc: post.created_at],
select: post.id
)
)
|> Enum.filter(&(tag_name in (&1.tags || [])))
|> Enum.map(& &1.id)
_other ->
[]