Skip to content

PostgreSQL and not using lib/pq for arrays #2960

Open
@papisz

Description

@papisz

What do you want to change?

Current state

In current state of the library, using queries with arrays generates code with a dependency to github.com/lib/pq, which is in maintenance mode.

Example from the docs:

func (q *Queries) ListAuthorsByIDs(ctx context.Context, ids []int) ([]Author, error) {
	rows, err := q.db.QueryContext(ctx, listAuthors, pq.Array(ids))

It would be great if it was possible to not have pq dependency here.

Implications

This might lead to some misleading situations, example:

The pgx lib, which is used often as a replacement for lib/pq, is possible to use in such way:

db, err := sql.Open("pgx", os.Getenv("DATABASE_URL"))

This means that if you use sqlc in the default database/sql mode with such command, you end up with:

  • imported pq dependency
  • but actually you're using pgx as a driver

Thank you in advance for looking into this issue.

What database engines need to be changed?

PostgreSQL

What programming language backends need to be changed?

Go

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions