porsager / porsager/postgres

Fetch custom type oids - use case: pgvector extension

Open
#1,115 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
8.7k
Forks
374
Avg merge
11d 16h
Merged PRs (30d)
1

Description

In order to use vector type of the pgvector extension, we currently need to start a temporary connection to the db to get the vector type oid and then add it in the options types. See https://github.com/porsager/postgres/issues/1041

Similar to fetchArrayTypes, it should be possible to get the oid to fill to and from properties of the custom type and thus make it look like this

let options = {
  types: {
    vector: {
      serialize: v => JSON.stringify(v),
      parse: v =>JSON.parse(v)
     }
  }
}

This OID lookup would only happen for types that don't have to and from defined. Or maybe only under a flag in the type definition: fetch_oid: true

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the existing fetchArrayTypes behavior and the custom types options described in the issue. Determine how missing to and from properties should trigger an OID lookup, then verify the result with the pgvector vector type example; done means custom types can serialize and parse without a temporary connection.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, postgresql
Domain
backend-api-design, databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.