typescript generated type of pgvector/vector is string
dejoma opened this issue · 5 comments
Enable Vector Extension in public schema, then create a table:
create table dejoma_test (
id serial primary key,
title text not null,
body text not null,
embedding vector(1536)
);
Then execute:
supabase gen types typescript --schema "public" --linked > example.ts
To find that:
dejoma_test: {
Row: {
body: string
embedding: string | null
id: number
title: string
}
Insert: {
body: string
embedding?: string | null
id?: number
title: string
}
Update: {
body?: string
embedding?: string | null
id?: number
title?: string
}
}
which then in turn get's flagged by my typescript server:
Please help, I (expect) that I can fix this locally by changing those types to number[]
after generating the fles.
Hey @dejoma, agreed the DX for vector
types could be better. The trouble is related to how PostgREST is returning pgvector values. See more context here:
#559
Ideally these would be number[]
everywhere.
Transferring this issue to the postgres-meta
repo. cc @soedirgo
In the mean time as a workaround you can try wrapping your embedding in a JSON.stringify()
, casting inline, or manually changing the Insert
type as you mention (note the Row
type may come back as string
... needs to be tested).
Closing this unless a better solution comes up for handling vector
types