Skip to content

sqlc.slice(): Generate code with unused imports #3065

Closed
@flrossetto

Description

@flrossetto

Version

1.24.0

What happened?

The code imports the unused "strings" package.

Relevant log output

// Code generated by sqlc. DO NOT EDIT.
// versions:
//   sqlc v1.24.0
// source: query.sql

package tutorial

import (
	"context"
	"strings"
)

const getAuthor = `-- name: GetAuthor :one
SELECT id, name, bio FROM authors
WHERE id = any($1)
`

func (q *Queries) GetAuthor(ctx context.Context, idList []int64) (Author, error) {
	row := q.db.QueryRow(ctx, getAuthor, idList)
	var i Author
	err := row.Scan(&i.ID, &i.Name, &i.Bio)
	return i, err
}

Database schema

CREATE TABLE authors (
  id   BIGSERIAL PRIMARY KEY,
  name text      NOT NULL,
  bio  text
);

SQL queries

-- name: GetAuthor :one
SELECT * FROM authors
WHERE id = any(sqlc.slice('id_list'));

Configuration

version: "2"
sql:
  - engine: "postgresql"
    queries: "query.sql"
    schema: "schema.sql"
    gen:
      go:
        package: "tutorial"
        out: "tutorial"
        sql_package: "pgx/v5"

Playground URL

https://play.sqlc.dev/p/7f1ba3b245cc4cbdf50a7512c4a598d701d80eda56de8ef60fd26393e3ca1605

What operating system are you using?

Linux

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

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