Skip to content

Code created with duplicated fields #2429

Open

Description

@leobrines

Version

Other

What happened?

Hi guys!

It generates an invalid go struct when there are duplicated fields at schema. Go compiler generates a redeclared field error.

type Tournament struct {
	ID     string
	Status sql.NullString
	Status sql.NullString
}

Using sqlc version 1.19.0

Relevant log output

No response

Database schema

CREATE TABLE tournaments (
    id VARCHAR(255) NOT NULL,
    status VARCHAR(255),
    status VARCHAR(255)
);

SQL queries

-- name: FindTournamentByID :one
SELECT *
FROM tournaments
WHERE id = ?;

Configuration

{
  "version": "1",
  "packages": [
    {
      "path": "sqlite",
      "name": "sqlite",
      "schema": "query.sql",
      "queries": "query.sql",
      "engine": "sqlite",
      "emit_json_tags": false,
      "emit_prepared_queries": true,
      "emit_interface": true
    }
  ]
}

Playground URL

https://play.sqlc.dev/p/9dadfd2d3b03f88c36209c864a83167e464cb327d8cb5a31aea62242b5b5fb58

What operating system are you using?

Windows

What database engines are you using?

SQLite

What type of code are you generating?

Go

Activity

  1. added
    bugSomething isn't working
    triageNew issues that hasn't been reviewed
    on Jul 11, 2023
  2. orisano commented on Jul 11, 2023

    @orisano
    Contributor

    I don't think SQLite allows duplicate columns to be defined in CREATE TABLE, what behavior do you expect?

  3. leobrines commented on Jul 11, 2023

    @leobrines
    Author

    It is expected it does not generate code that cannot compile

  4. added this to the v1.20.0 milestone on Jul 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions