porsager / porsager/postgres

Feature request: Static array types with fetch_types false

Open
#1,164 0 comments 1 reaction 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

The fetch_types: false option breaks the serializing/parsing of array types. As an example, the following fails:

import postgres from 'postgres'

const sql = postgres({
  fetch_types: false
})

const result = await sql`SELECT * FROM unnest(${['foo', 'bar']}::TEXT[])`
// Throws: `PostgresError: malformed array literal: "foo,bar"`

It would be nice to have the option to pass static typeOID -> arrayTypeOID mappings in the options to have that work without incurring the cost of fetching the OIDs from the database.

An automatic fallback with standard type OIDs could also be an option with fetch_types: false considering these appear to be stable?

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 running the supplied fetch_types: false example and tracing the array serialization/parsing path. Investigate how typeOID and arrayTypeOID information is obtained, then define coverage for the requested static mapping or standard-OID fallback. Done means the example works without fetching types and the behavior is tested.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.