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:
Luis Novo 2026-01-16 09:33:01 -03:00 committed by GitHub
parent da8c98b178
commit 809a1d0741
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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