Skip to content

Fetch custom type oids - use case: pgvector extension #1115

Closed

Description

@haikyuu

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 #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

Activity

  1. haggen commented on Mar 30, 2026

    @haggen

    Exactly my use case, with the addition of bit mask columns.

    The abstract is that we have to start a simpler connection pool to be able to start the definitive connection pool.

    The solution would be, either:

    1. To be able to parameterize the already established method to fetch database type OID so it can query additional custom types.
    2. To have a lazy connection pool initialization, so instead of having to feed the database types OID before the pool is started, it waits for when a connection is actually needed.
  2. porsager commented on Oct 29, 2026

    @porsager
    Owner

    v4 takes custom types by name: to: 'vector' and from: ['vector'], looked up when the pool starts, with their array types. See Custom Types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions