sqlc icon indicating copy to clipboard operation
sqlc copied to clipboard

custom struct tags are not emmited

Open bluebrown opened this issue 1 year ago • 2 comments

Version

1.25.0

What happened?

I am trying to set a custom struct tag but its not generated with the model.

Relevant log output

// Code generated by sqlc. DO NOT EDIT.
// versions:
//   sqlc v1.25.0

package store

import (
	"database/sql"
)

type Test struct {
	Nullstring sql.NullString
}

Database schema

create table test (
  nullstring text
)

SQL queries

-- name: read :one
select * from test where nullstring = ?;

Configuration

version: "2"
sql:
- engine: sqlite
  queries: ./query.sql
  schema: ./schema.sql
  gen:
    go:
      package: store
      out: ./store/
      overrides:
      - db_type: text
        nullable: true
        go_struct_tag: a:"b"

Playground URL

No response

What operating system are you using?

Linux

What database engines are you using?

SQLite

What type of code are you generating?

Go

bluebrown avatar Jan 15 '24 19:01 bluebrown

This might just be a YAML ambiguity issue - does it work if you change the tagline to:

go_struct_tag: 'a:"b"'

rishi-kulkarni avatar Jan 27 '24 21:01 rishi-kulkarni

Seems that it's only working if a column is set, so if "globally scoped" to a type it doesn't write it to the file, but if a column like "countdowns.date" is set it works.

emanuelturis avatar Mar 22 '24 14:03 emanuelturis