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 datetime import datetime
|
||||||
from typing import Any
|
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.dialects.postgresql import JSONB
|
||||||
from sqlalchemy.ext.asyncio import AsyncSession
|
from sqlalchemy.ext.asyncio import AsyncSession
|
||||||
from sqlmodel import col
|
from sqlmodel import col
|
||||||
|
|
@ -63,10 +63,7 @@ class MetadataFieldDefinitionService:
|
||||||
|
|
||||||
if scope:
|
if scope:
|
||||||
stmt = stmt.where(
|
stmt = stmt.where(
|
||||||
func.jsonb_contains(
|
cast(MetadataFieldDefinition.scope, JSONB).op('?')(scope)
|
||||||
cast(MetadataFieldDefinition.scope, JSONB),
|
|
||||||
func.cast(f'["{scope}"]', JSONB)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
stmt = stmt.order_by(col(MetadataFieldDefinition.created_at).desc())
|
stmt = stmt.order_by(col(MetadataFieldDefinition.created_at).desc())
|
||||||
|
|
@ -279,10 +276,7 @@ class MetadataFieldDefinitionService:
|
||||||
|
|
||||||
if scope:
|
if scope:
|
||||||
stmt = stmt.where(
|
stmt = stmt.where(
|
||||||
func.jsonb_contains(
|
cast(MetadataFieldDefinition.scope, JSONB).op('?')(scope)
|
||||||
cast(MetadataFieldDefinition.scope, JSONB),
|
|
||||||
func.cast(f'["{scope}"]', JSONB)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
stmt = stmt.order_by(col(MetadataFieldDefinition.created_at).desc())
|
stmt = stmt.order_by(col(MetadataFieldDefinition.created_at).desc())
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue