Skip to content

Remove use of pq.Array #1276

Description

@johanbrandhorst

Version

1.10.0

What happened?

I generated methods for a table with a text array. I expected it not to add a dependency on lib/pq since #472 is fixed.

Discussion: Ideally I would have liked this to automatically detect the array type and use https://pkg.go.dev/github.com/jackc/pgtype#TextArray, but I expect that sort of thing might be hard to do for all the different array types supported by Postgres. I don't know if there is some halfway implementation we can do.

Relevant log output

No response

Database schema

-- Example queries for sqlc
CREATE TABLE authors (
  id   BIGSERIAL PRIMARY KEY,
  names text[]      NOT NULL
);

SQL queries

-- name: GetAuthor :one
SELECT * FROM authors
WHERE id = $1 LIMIT 1;

Configuration

{
  "version": "1",
  "packages": [
    {
      "path": "db",
      "engine": "postgresql",
      "schema": "query.sql",
      "queries": "query.sql"
    }
  ]
}

Playground URL

https://play.sqlc.dev/p/224d4391b08fb5d3d3651f006792dc02426547c851d4138ecac512db2fdf419c

What operating system are you using?

Linux, macOS

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

Activity

  1. added
    bugSomething isn't working
    triageNew issues that hasn't been reviewed
    on Nov 8, 2021
  2. mvrhov commented on Nov 9, 2021

    @mvrhov

    You don't need any array stuff with pgx. It just works. the removal of pq.Array is enough.

  3. kyleconroy commented on Feb 22, 2023

    @kyleconroy
    Collaborator

    This has been fixed as of 1.17.2. You'll need to set sql_package to either pgx/v4 or pgx/v5.

    {
      "version": "1",
      "packages": [
        {
          "path": "db",
          "engine": "postgresql",
          "sql_package": "pgx/v5",
          "schema": "query.sql",
          "queries": "query.sql"
        }
      ]
    }
    

    https://play.sqlc.dev/p/58bf734d05bad15bc346420dfa0615c795033aaf867f070a5920ec336064dd5f

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions