diff --git a/crates/bindings-typescript/src/lib/query.ts b/crates/bindings-typescript/src/lib/query.ts index 37743ccd0be..fda31f68f45 100644 --- a/crates/bindings-typescript/src/lib/query.ts +++ b/crates/bindings-typescript/src/lib/query.ts @@ -12,6 +12,7 @@ import type { } from './type_builders'; import type { Values } from './type_util'; import type { Bool as SatsBool } from './algebraic_type_variants'; +import { Uuid } from './uuid'; /** * Helper to get the set of table names. @@ -623,6 +624,7 @@ type LiteralValue = | bigint | boolean | Identity + | Uuid | Timestamp | ConnectionId; @@ -851,7 +853,11 @@ function literalValueToSql(value: unknown): string { if (value === null || value === undefined) { return 'NULL'; } - if (value instanceof Identity || value instanceof ConnectionId) { + if ( + value instanceof Identity || + value instanceof ConnectionId || + value instanceof Uuid + ) { // We use this hex string syntax. return `0x${value.toHexString()}`; } diff --git a/crates/bindings-typescript/src/lib/uuid.ts b/crates/bindings-typescript/src/lib/uuid.ts index 2216e1e9499..097424c8da3 100644 --- a/crates/bindings-typescript/src/lib/uuid.ts +++ b/crates/bindings-typescript/src/lib/uuid.ts @@ -1,5 +1,6 @@ import { Timestamp } from './timestamp'; import { AlgebraicType } from './algebraic_type.ts'; +import { u128ToHexString } from './util'; export type UuidAlgebraicType = { tag: 'Product'; @@ -226,10 +227,14 @@ export class Uuid { return new Uuid(v); } + /** Convert to hex string without a 0x prefix. */ + toHexString(): string { + return u128ToHexString(this.asBigInt()); + } + /** Convert to string (hyphenated form). */ toString(): string { - const bytes = Uuid.bigIntToBytes(this.__uuid__); - const hex = [...bytes].map(b => b.toString(16).padStart(2, '0')).join(''); + const hex = this.toHexString(); // Format as 8-4-4-4-12 return (