Skip to content

Missing Imports for pgtype.Array with netip types #2079

@rhyselsmore

Description

@rhyselsmore

Version

1.16.0

What happened?

Version: 1.17.0

It appears that arrays of netip.Addr/netip.Prefix do not add the relevant imports on generated files.

I'll dig into this shortly, just wanted to add it as a bug.

Relevant log output

// Code generated by sqlc. DO NOT EDIT.
// versions:
//   sqlc v1.17.0
// source: route_update.sql

package db

import (
	"context"

	"github.com/jackc/pgx/v5/pgtype"
)

const createRouteUpdate = `-- name: CreateRouteUpdate :one
INSERT INTO route_updates (shard_ips)
  VALUES ($1::inet[])
  RETURNING id, shard_ips, created_at
`

type CreateRouteUpdateParams struct {
	ShardIps pgtype.Array[netip.Addr]
}

func (q *Queries) CreateRouteUpdate(ctx context.Context, db DBTX, arg CreateRouteUpdateParams) (RouteUpdate, error) {
	row := db.QueryRow(ctx, createRouteUpdate, arg.ShardIps)
	var i RouteUpdate
	err := row.Scan(
		&i.ID,
		&i.ShardIps,
		&i.CreatedAt,
	)
	return i, err
}

Database schema

-- Route Updates
CREATE TABLE route_updates (
  id              bigserial NOT NULL,
  shard_ips       inet[] NOT NULL,
  created_at      timestamptz NOT NULL DEFAULT now()
);

SQL queries

-- name: CreateRouteUpdate :one
INSERT INTO route_updates (shard_ips)
  VALUES (@shard_ips::inet[])
  RETURNING *;

Configuration

version: 1
packages:
  - path: "../"
    name: "db"
    engine: "postgresql"
    sql_package: "pgx/v5"
    schema: "./migration"
    emit_methods_with_db_argument: true
    queries:
      - "queries"

Playground URL

Playground does not support v1.17.0

What operating system are you using?

macOS

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriageNew issues that hasn't been reviewed

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions