Skip to content

Commit 87f6f1d

Browse files
committed
fix: use record cast for fn::node_info() parameter handling
Fixed fn::node_info() to properly handle SurrealDB record IDs using <record> type casting instead of type::thing() construction. Root cause: SurrealDB stores IDs as record types (nodes:⟨uuid⟩) and when passed as string parameters, they need to be cast back to record type for FROM clauses to work. Fix: - Build full record ID string: "nodes:uuid" (handles both formats) - Use <record> cast: FROM ONLY <record> $full_id - Return $res directly (FROM ONLY returns single object, not array) This handles: 1. Full record ID string: "nodes:0002cb76-..." → used as-is 2. Just UUID: "0002cb76-..." → prepended with "nodes:" 3. Record cast: <record> converts string to proper Thing type Test with: SELECT fn::node_info('0002cb76-bdea-4461-b489-cc76476ee863'); SELECT fn::node_info('nodes:0002cb76-bdea-4461-b489-cc76476ee863');
1 parent 7d4f4ac commit 87f6f1d

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

schema/codegraph.surql

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -294,12 +294,14 @@ DEFINE INDEX IF NOT EXISTS idx_symbol_embeddings_edge
294294
-- FUNCTION: node_info (UNCHANGED)
295295
-- -----------------------------------------------------------------------------
296296
DEFINE FUNCTION fn::node_info($node_id: string) {
297-
LET $record_id = IF string::contains($node_id, ':') THEN
298-
type::thing($node_id)
297+
-- Build full record ID string ("nodes:uuid" format)
298+
LET $full_id = IF string::starts_with($node_id, 'nodes:') THEN
299+
$node_id
299300
ELSE
300-
type::thing('nodes', $node_id)
301+
string::concat('nodes:', $node_id)
301302
END;
302303

304+
-- Cast string to record and query
303305
LET $res = SELECT
304306
id,
305307
name,
@@ -312,10 +314,9 @@ DEFINE FUNCTION fn::node_info($node_id: string) {
312314
start_line: start_line,
313315
end_line: end_line
314316
} AS location
315-
FROM ONLY $record_id
316-
LIMIT 1;
317+
FROM ONLY <record> $full_id;
317318

318-
RETURN $res[0];
319+
RETURN $res;
319320
};
320321

321322
-- -----------------------------------------------------------------------------

0 commit comments

Comments
 (0)