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

fix(codegen/golang): Fixed detection of the used package #2597

Merged
merged 2 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions internal/codegen/golang/imports.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,10 @@ func (i *importer) interfaceImports() fileImports {
}
}
if !q.Arg.isEmpty() {
if hasPrefixIgnoringSliceAndPointerPrefix(q.Arg.Type(), name) {
return true
for _, f := range q.Arg.Fields() {
if hasPrefixIgnoringSliceAndPointerPrefix(f.Type, name) {
return true
}
}
}
}
Expand Down Expand Up @@ -311,16 +313,11 @@ func (i *importer) queryImports(filename string) fileImports {
}
}
if !q.Arg.isEmpty() {
if q.Arg.EmitStruct() {
for _, f := range q.Arg.Struct.Fields {
if hasPrefixIgnoringSliceAndPointerPrefix(f.Type, name) {
return true
}
for _, f := range q.Arg.Fields() {
if hasPrefixIgnoringSliceAndPointerPrefix(f.Type, name) {
return true
}
}
if hasPrefixIgnoringSliceAndPointerPrefix(q.Arg.Type(), name) {
return true
}
}
}
return false
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
CREATE TABLE notice (
id INTEGER NOT NULL,
cnt INTEGER NOT NULL,
status TEXT NOT NULL,
notice_at TIMESTAMP,
created_at TIMESTAMP NOT NULL
);

-- name: MarkNoticeDone :exec
UPDATE notice
SET status='done', notice_at=$1
WHERE id=$2;

-- name: CreateNotice :exec
INSERT INTO notice (cnt, created_at)
VALUES ($1, $2);
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"version": "1",
"packages": [
{
"path": "go",
"engine": "postgresql",
"schema": "query.sql",
"queries": "query.sql",
"query_parameter_limit": 2,
"emit_interface": true,
"name": "querytest"
}
]
}
Loading