| 119 | } |
| 120 | |
| 121 | func (i *importer) dbImports() fileImports { |
| 122 | var pkg []ImportSpec |
| 123 | std := []ImportSpec{ |
| 124 | {Path: "context"}, |
| 125 | } |
| 126 | |
| 127 | sqlpkg := parseDriver(i.Options.SqlPackage) |
| 128 | switch sqlpkg { |
| 129 | case opts.SQLDriverPGXV4: |
| 130 | pkg = append(pkg, ImportSpec{Path: "github.com/jackc/pgconn"}) |
| 131 | pkg = append(pkg, ImportSpec{Path: "github.com/jackc/pgx/v4"}) |
| 132 | case opts.SQLDriverPGXV5: |
| 133 | pkg = append(pkg, ImportSpec{Path: "github.com/jackc/pgx/v5/pgconn"}) |
| 134 | pkg = append(pkg, ImportSpec{Path: "github.com/jackc/pgx/v5"}) |
| 135 | default: |
| 136 | std = append(std, ImportSpec{Path: "database/sql"}) |
| 137 | if i.Options.EmitPreparedQueries { |
| 138 | std = append(std, ImportSpec{Path: "fmt"}) |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | sort.Slice(std, func(i, j int) bool { return std[i].Path < std[j].Path }) |
| 143 | sort.Slice(pkg, func(i, j int) bool { return pkg[i].Path < pkg[j].Path }) |
| 144 | return fileImports{Std: std, Dep: pkg} |
| 145 | } |
| 146 | |
| 147 | var stdlibTypes = map[string]string{ |
| 148 | "json.RawMessage": "encoding/json", |