Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Column override with imported go-type invalid when pointer:true #2125

Closed
vmalyavin opened this issue Mar 2, 2023 · 0 comments
Closed

Column override with imported go-type invalid when pointer:true #2125

vmalyavin opened this issue Mar 2, 2023 · 0 comments
Labels
bug Something isn't working triage New issues that hasn't been reviewed

Comments

@vmalyavin
Copy link

vmalyavin commented Mar 2, 2023

Version

v1.17.2

What happened?

When override table column with imported type as pointer - type is not imports in queries.sql.go

example

override with type github.com/some/package/types.CustomTypeName as pointer
https://play.sqlc.dev/p/ed5f9342ff8eda757c7bb8d1da9b27a94a734e2b98a6c8f73d08a10736ae9dae

{
  "import": "github.com/some/package/types",
  "type": "CustomTypeName",
  "pointer": true
}

generates query.sql.go
without override type import:

package model

import (
	"context"

	"github.com/google/uuid"
)

valid example

same override without pointer flag
https://play.sqlc.dev/p/19de6fe73aa60dba17237db3f83530cf2ad3c4b8fb61c891b12ec3143496cff9

{
  "import": "github.com/some/package/types",
  "type": "CustomTypeName"
}

generates query.sql.go
with valid import:

package model

import (
	"context"

	"github.com/google/uuid"
	"github.com/some/package/types"
)

Relevant log output

No response

Database schema

create table vendors
(
    id    uuid primary key,
    data jsonb
);

SQL queries

/* name: GetVendors :one */
SELECT v.*, 'something' as custom FROM vendors v;

Configuration

{
  "version": "2",
  "sql": [
    {
      "schema": "query.sql",
      "queries": "query.sql",
      "engine": "postgresql",
      "gen": {
        "go": {
          "package": "model",
          "out": "db",
          "overrides": [
            {
              "column": "vendors.data",
			  "go_type": {
			  	"import": "github.com/some/package/types",
				"type": "CustomTypeName",
				"pointer": true
			  },
              "nullable": true
            }
          ]
        }
      }
    }
  ]
}

Playground URL

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

What operating system are you using?

macOS

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

@vmalyavin vmalyavin added bug Something isn't working triage New issues that hasn't been reviewed labels Mar 2, 2023
@kyleconroy kyleconroy changed the title v1.17.2 Column override with imported go-type invalid when pointer:true Column override with imported go-type invalid when pointer:true Mar 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage New issues that hasn't been reviewed
Projects
None yet
Development

No branches or pull requests

2 participants