fix(api): correct embedded flag check in source listing (#439)
Change embedded check from `!= NONE` to `!= []` because SurrealDB's SELECT VALUE returns an empty array [] when no results found, not NONE. The comparison `[] != NONE` evaluates to true, causing all sources to incorrectly show as embedded. Fixes #397
This commit is contained in:
parent
da8c98b178
commit
809a1d0741
1 changed files with 2 additions and 2 deletions
|
|
@ -185,7 +185,7 @@ async def get_sources(
|
|||
query = f"""
|
||||
SELECT id, asset, created, title, updated, topics, command,
|
||||
(SELECT VALUE count() FROM source_insight WHERE source = $parent.id GROUP ALL)[0].count OR 0 AS insights_count,
|
||||
((SELECT VALUE id FROM source_embedding WHERE source = $parent.id LIMIT 1)) != NONE AS embedded
|
||||
(SELECT VALUE id FROM source_embedding WHERE source = $parent.id LIMIT 1) != [] AS embedded
|
||||
FROM (select value in from reference where out=$notebook_id)
|
||||
{order_clause}
|
||||
LIMIT $limit START $offset
|
||||
|
|
@ -204,7 +204,7 @@ async def get_sources(
|
|||
query = f"""
|
||||
SELECT id, asset, created, title, updated, topics, command,
|
||||
(SELECT VALUE count() FROM source_insight WHERE source = $parent.id GROUP ALL)[0].count OR 0 AS insights_count,
|
||||
((SELECT VALUE id FROM source_embedding WHERE source = $parent.id LIMIT 1)) != NONE AS embedded
|
||||
(SELECT VALUE id FROM source_embedding WHERE source = $parent.id LIMIT 1) != [] AS embedded
|
||||
FROM source
|
||||
{order_clause}
|
||||
LIMIT $limit START $offset
|
||||
|
|
|
|||
Loading…
Reference in a new issue