sqlc icon indicating copy to clipboard operation
sqlc copied to clipboard

Trouble getting `emit_pointers_for_null_types` to apply to SQLite target

Open ddowl opened this issue 1 year ago • 1 comments

Version

1.24.0

What happened?

I'm having some trouble getting the emit_pointers_for_null_types option to apply to a SQLite schema & queries, i.e. sql.Null* types aren't replaced with their pointer primitive variants. I've checked that other kinds of Go options work correctly, like emit_result_struct_pointers, emit_interface, and emit_json_tags, but not the null type option. I produced a minimal example that reproduces my issue in this playground link. Not sure if this is a SQLite specific issue, since we have a similar Postgres schema where emit_pointers_for_null_types works fine.

Relevant log output

No response

Database schema

CREATE TABLE dummy (
  "id" text NOT NULL PRIMARY KEY,
  "col_1" text
);

SQL queries

-- name: GetDummy :one
SELECT * FROM dummy WHERE id = ?1;

-- name: GetDummies :many
SELECT * FROM dummy;

-- name: CreateDummy :one
INSERT INTO dummy (id, col_1) VALUES (?1, ?2)
RETURNING *;

-- name: UpdateDummy :one
UPDATE dummy SET col_1 = ?2 WHERE id = ?1
RETURNING *;

-- name: DeleteDummy :exec
DELETE FROM dummy WHERE id = ?1;

Configuration

version: "2"
sql:
- schema: "schema.sql"
  queries: "query.sql"
  engine: "sqlite"
  gen:
    go:
      package: "sqlc"
      out: "./"
      emit_pointers_for_null_types: true

Playground URL

https://play.sqlc.dev/p/3d5b8939ebe833a68c11808b30ed27c0907bd2cbaf9422951775e7de6349e949

What operating system are you using?

macOS

What database engines are you using?

SQLite

What type of code are you generating?

Go

ddowl avatar Jan 30 '24 22:01 ddowl

This was fixed in 1.25.0 (https://github.com/sqlc-dev/sqlc/pull/3026), your playground example works when I update the version: https://play.sqlc.dev/p/a3eacaca248da3c046efd82fca0056dd995a9a8eac903d5f8eb3117cf14cce84

gregoryjjb avatar Feb 16 '24 19:02 gregoryjjb