supabase / postgres-meta

A RESTful API for managing your Postgres. Fetch tables, add roles, and run queries
https://supabase.com
Apache License 2.0
941 stars 126 forks source link

feat: support vector data type when generating typescript types #559

Closed gregnr closed 1 year ago

gregnr commented 1 year ago

Adds pgvector's vector data type to TypeScript generation logic to produce a number[] string type.

Edit: vector actually produces a string, eg "[1,2,3]".

soedirgo commented 1 year ago

Thanks! I'm actually getting vector columns as text from PostgREST though:

create table t (c vector(3));
insert into t values ('[1,2,3]'), ('[4,5,6]');
[
  {
    "c": "[1,2,3]"
  },
  {
    "c": "[4,5,6]"
  }
]
soedirgo commented 1 year ago

Ah seems like I can do:

> curl 'https://<...>.supabase.co/rest/v1/t?select=c::_float4' -H 'Authorization: Bearer <...>' -H 'apikey: <...>' | jq

[
  {
    "c": [
      1,
      2,
      3
    ]
  },
  {
    "c": [
      4,
      5,
      6
    ]
  }
]

This needs casting support on postgrest-js though - will take a look at that

gregnr commented 1 year ago

Woah, TIL you can cast over PostgREST 😃

This needs casting support on postgrest-js though - will take a look at that

Thanks! I imagine this means we should default it as a string instead (we probably shouldn't implicitly cast)?

soedirgo commented 1 year ago

we should default it as a string instead (we probably shouldn't implicitly cast)?

Yup, agreed :+1:

gregnr commented 1 year ago

Great, updated it to a string now.

github-actions[bot] commented 1 year ago

:tada: This PR is included in version 0.63.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: