From 1ee023ba2d25b632e5b93300917aa3017ce4500a Mon Sep 17 00:00:00 2001 From: Noa Date: Mon, 23 Feb 2026 13:22:16 -0600 Subject: [PATCH] [TS] Fix returning a query from a view that returns an option --- crates/bindings-typescript/src/server/views.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/bindings-typescript/src/server/views.ts b/crates/bindings-typescript/src/server/views.ts index accd0c92563..c81cad2b1f7 100644 --- a/crates/bindings-typescript/src/server/views.ts +++ b/crates/bindings-typescript/src/server/views.ts @@ -18,7 +18,11 @@ import { } from '../lib/type_builders'; import { bsatnBaseSize, toPascalCase } from '../lib/util'; import type { ReadonlyDbView } from './db_view'; -import { type QueryBuilder, type RowTypedQuery } from './query'; +import { + isRowTypedQuery, + type QueryBuilder, + type RowTypedQuery, +} from './query'; import { exportContext, registerExport, @@ -178,7 +182,7 @@ export function registerView< const originalFn = fn; fn = ((ctx: ViewCtx, args: InferTypeOfRow) => { const ret = originalFn(ctx, args); - return ret == null ? [] : [ret]; + return isRowTypedQuery(ret) ? ret : ret == null ? [] : [ret]; }) as any; returnType = AlgebraicType.Array( returnType.value.variants[0].algebraicType