Skip to content

case expression returns interface{} #2937

Open
@araufdogan

Description

@araufdogan

Version

1.23.0

What happened?

When I run sqlc generate, it generates interface{} for my custom select fields.
I couldn't find how to define type for this fields. Is there any way to do it?

Relevant log output

No response

Database schema

CREATE TABLE test_table (
  id int unsigned NOT NULL AUTO_INCREMENT,
  val1 int NOT NULL,
  val2 int NOT NULL,
  PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

SQL queries

-- name: GetData :many
SELECT test_table.*, 
CASE
WHEN test_table.val1 = 100 THEN test_table.val1 ELSE test_table.val2
END AS final_val
from test_table;

Configuration

{
  "version": "2",
  "sql": [{
    "schema": "schema.sql",
    "queries": "query.sql",
    "engine": "mysql",
    "gen": {
      "go": {
        "out": "db"
      }
    }
  }]
}

Playground URL

https://play.sqlc.dev/p/ded46511e671b26f426512a2248d30b6d7707ca404b55d163d0c1705e744791c

What operating system are you using?

macOS

What database engines are you using?

MySQL

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