diff --git a/crates/bindings-typescript/src/react/useTable.ts b/crates/bindings-typescript/src/react/useTable.ts index fda88a0835f..569f66fb43f 100644 --- a/crates/bindings-typescript/src/react/useTable.ts +++ b/crates/bindings-typescript/src/react/useTable.ts @@ -10,6 +10,7 @@ import { type EventContextInterface } from '../sdk/db_connection_impl'; import type { ConnectionState } from './connection_state'; import type { UntypedRemoteModule } from '../sdk/spacetime_module'; import type { RowType, UntypedTableDef } from '../lib/table'; +import { Uuid } from '../lib/uuid'; import type { Prettify } from '../lib/type_util'; export interface UseTableCallbacks { @@ -18,7 +19,7 @@ export interface UseTableCallbacks { onUpdate?: (oldRow: RowType, newRow: RowType) => void; } -export type Value = string | number | boolean; +export type Value = string | number | boolean | Uuid; export type Expr = | { type: 'eq'; key: Column; value: Value } @@ -76,6 +77,7 @@ export function evaluate( ): boolean { switch (expr.type) { case 'eq': { + // The actual value of the Column const v = row[expr.key]; if ( typeof v === 'string' || @@ -84,6 +86,16 @@ export function evaluate( ) { return v === expr.value; } + if (typeof v === 'object') { + // Value of the Column and passed Value are both a Uuid so do an integer comparison. + if (v instanceof Uuid && expr.value instanceof Uuid) { + return v.asBigInt() === expr.value.asBigInt(); + } + // Value of the Column is a Uuid but passed Value is a String so compare them via string. + if (v instanceof Uuid && typeof expr.value === 'string') { + return v.toString() === expr.value; + } + } return false; } case 'and': @@ -105,6 +117,13 @@ function formatValue(v: Value): string { return Number.isFinite(v) ? String(v) : `'${String(v)}'`; case 'boolean': return v ? 'TRUE' : 'FALSE'; + case 'object': { + if (v instanceof Uuid) { + return `'${v.toString()}'`; + } + + return ''; + } } }