Skip to content

Go SQLC Generate is outputting a DBTX interface that is not implemented by *sql.DB golang internal library #3743

Closed
@jasonwebb3152

Description

@jasonwebb3152

Version

1.27.0

What happened?

Not sure if I'm doing something as I am new to sqlc, but it seems to be outputting an interface that is not compliant with the sql.DB type in go.

Here is my go version: go version go1.23.4 linux/amd64
I am using sqlc v1.27.0.

Here is my sqlc.yaml file:

version: "2"
plugins:
- name: golang
  wasm:
    url: https://downloads.sqlc.dev/plugin/sqlc-gen-go_1.4.0.wasm
    sha256: e8206081686f95b461daf91a307e108a761526c6768d6f3eca9781b0726b7ec8
sql:
- schema: "./db/migration"
  queries: "./db/query"
  engine: "postgresql"
  codegen:
  - plugin: golang
    out: "./db/sqlc"
    options:
      package: "db"
      sql_package: pgx/v5
      emit_json_tags: true
      emit_prepared_queries: false
      emit_interface: false
      emit_exact_table_names: false
      emit_pointers_for_null_types: true
      overrides:
        - db_type: "timestamptz"
          go_type:
            import: "time"
            type: "Time"

And here is the DBTX interface that is outputted:

type DBTX interface {
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
}

I believe these methods should all have the suffix: *Context for sql.DB to implement the interface. I can't find anything wrong with the yaml file. Perhaps I have some incompatibility between the versions of go and sqlc I am using, but I don't believe so.

Relevant log output

No response

Database schema

No response

SQL queries

No response

Configuration

No response

Playground URL

No response

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