Skip to content

Commit fbebacb

Browse files
jlisthoodDaniel Kozlowski
authored andcommitted
fix: missing imports (sqlc-dev#1637)
1 parent 2ff464e commit fbebacb

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

internal/codegen/golang/imports.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,8 @@ func (i *importer) queryImports(filename string) fileImports {
309309
}
310310
}
311311
}
312-
if strings.HasPrefix(q.Ret.Type(), name) {
312+
retType := strings.TrimPrefix(q.Ret.Type(), "[]")
313+
if strings.HasPrefix(retType, name) {
313314
return true
314315
}
315316
}
@@ -322,7 +323,8 @@ func (i *importer) queryImports(filename string) fileImports {
322323
}
323324
}
324325
}
325-
if strings.HasPrefix(q.Arg.Type(), name) {
326+
argType := strings.TrimPrefix(q.Arg.Type(), "[]")
327+
if strings.HasPrefix(argType, name) {
326328
return true
327329
}
328330
}
@@ -414,7 +416,8 @@ func (i *importer) batchImports(filename string) fileImports {
414416
}
415417
}
416418
}
417-
if strings.HasPrefix(q.Ret.Type(), name) {
419+
retType := strings.TrimPrefix(q.Ret.Type(), "[]")
420+
if strings.HasPrefix(retType, name) {
418421
return true
419422
}
420423
}
@@ -427,7 +430,8 @@ func (i *importer) batchImports(filename string) fileImports {
427430
}
428431
}
429432
}
430-
if strings.HasPrefix(q.Arg.Type(), name) {
433+
argType := strings.TrimPrefix(q.Arg.Type(), "[]")
434+
if strings.HasPrefix(argType, name) {
431435
return true
432436
}
433437
}

0 commit comments

Comments
 (0)