fix: correct metadata scope filter SQL query for PostgreSQL [AC-IDSMETA-16]
This commit is contained in:
parent
99c17d57b1
commit
714dc8c480
|
|
@ -9,7 +9,7 @@ import uuid
|
|||
from datetime import datetime
|
||||
from typing import Any
|
||||
|
||||
from sqlalchemy import select, func, cast, text
|
||||
from sqlalchemy import select, func, cast, text, any_
|
||||
from sqlalchemy.dialects.postgresql import JSONB
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from sqlmodel import col
|
||||
|
|
@ -63,10 +63,7 @@ class MetadataFieldDefinitionService:
|
|||
|
||||
if scope:
|
||||
stmt = stmt.where(
|
||||
func.jsonb_contains(
|
||||
cast(MetadataFieldDefinition.scope, JSONB),
|
||||
func.cast(f'["{scope}"]', JSONB)
|
||||
)
|
||||
cast(MetadataFieldDefinition.scope, JSONB).op('?')(scope)
|
||||
)
|
||||
|
||||
stmt = stmt.order_by(col(MetadataFieldDefinition.created_at).desc())
|
||||
|
|
@ -279,10 +276,7 @@ class MetadataFieldDefinitionService:
|
|||
|
||||
if scope:
|
||||
stmt = stmt.where(
|
||||
func.jsonb_contains(
|
||||
cast(MetadataFieldDefinition.scope, JSONB),
|
||||
func.cast(f'["{scope}"]', JSONB)
|
||||
)
|
||||
cast(MetadataFieldDefinition.scope, JSONB).op('?')(scope)
|
||||
)
|
||||
|
||||
stmt = stmt.order_by(col(MetadataFieldDefinition.created_at).desc())
|
||||
|
|
|
|||
Loading…
Reference in New Issue