Skip to content

Commit 56ea963

Browse files
committed
refactor(cmd): keep OutputPair and ResultProcessor names from main
Unexported aliases added no encapsulation (same package) and only increase PR noise. Restore AnalyzerDatabase field alignment as on main. Made-with: Cursor
1 parent b7aec34 commit 56ea963

5 files changed

Lines changed: 20 additions & 20 deletions

File tree

internal/cmd/generate.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -186,23 +186,23 @@ type generator struct {
186186
codegenHandlerOverride grpc.ClientConnInterface
187187
}
188188

189-
func (g *generator) Pairs(ctx context.Context, conf *config.Config) []outputPair {
190-
var pairs []outputPair
189+
func (g *generator) Pairs(ctx context.Context, conf *config.Config) []OutputPair {
190+
var pairs []OutputPair
191191
for _, sql := range conf.SQL {
192192
if sql.Gen.Go != nil {
193-
pairs = append(pairs, outputPair{
193+
pairs = append(pairs, OutputPair{
194194
SQL: sql,
195195
Gen: config.SQLGen{Go: sql.Gen.Go},
196196
})
197197
}
198198
if sql.Gen.JSON != nil {
199-
pairs = append(pairs, outputPair{
199+
pairs = append(pairs, OutputPair{
200200
SQL: sql,
201201
Gen: config.SQLGen{JSON: sql.Gen.JSON},
202202
})
203203
}
204204
for i := range sql.Codegen {
205-
pairs = append(pairs, outputPair{
205+
pairs = append(pairs, OutputPair{
206206
SQL: sql,
207207
Plugin: &sql.Codegen[i],
208208
})
@@ -211,7 +211,7 @@ func (g *generator) Pairs(ctx context.Context, conf *config.Config) []outputPair
211211
return pairs
212212
}
213213

214-
func (g *generator) ProcessResult(ctx context.Context, combo config.CombinedSettings, sql outputPair, result *compiler.Result) error {
214+
func (g *generator) ProcessResult(ctx context.Context, combo config.CombinedSettings, sql OutputPair, result *compiler.Result) error {
215215
out, resp, err := codegen(ctx, combo, sql, result, g.codegenHandlerOverride)
216216
if err != nil {
217217
return err
@@ -282,7 +282,7 @@ func parse(ctx context.Context, name, dir string, sql config.SQL, combo config.C
282282
return c.Result(), false
283283
}
284284

285-
func codegen(ctx context.Context, combo config.CombinedSettings, sql outputPair, result *compiler.Result, codegenOverride grpc.ClientConnInterface) (string, *plugin.GenerateResponse, error) {
285+
func codegen(ctx context.Context, combo config.CombinedSettings, sql OutputPair, result *compiler.Result, codegenOverride grpc.ClientConnInterface) (string, *plugin.GenerateResponse, error) {
286286
defer trace.StartRegion(ctx, "codegen").End()
287287
req := codeGenRequest(result, combo)
288288
var handler grpc.ClientConnInterface

internal/cmd/plugin_engine.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929
// engine plugin via ParseRequest; the responses are turned into compiler.Result and
3030
// passed to ProcessResult. No AST or compiler parsing is used.
3131
// When inputs.FileContents is set, schema/query bytes are taken from it (no disk read).
32-
func runPluginQuerySet(ctx context.Context, rp resultProcessor, name, dir string, sql outputPair, combo config.CombinedSettings, inputs *sourceFiles, o *Options) error {
32+
func runPluginQuerySet(ctx context.Context, rp ResultProcessor, name, dir string, sql OutputPair, combo config.CombinedSettings, inputs *sourceFiles, o *Options) error {
3333
enginePlugin, found := config.FindEnginePlugin(&combo.Global, string(combo.Package.Engine))
3434
if !found || enginePlugin.Process == nil {
3535
e := string(combo.Package.Engine)

internal/cmd/process.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@ import (
1919
"github.com/sqlc-dev/sqlc/internal/opts"
2020
)
2121

22-
type outputPair struct {
22+
type OutputPair struct {
2323
Gen config.SQLGen
2424
Plugin *config.Codegen
2525

2626
config.SQL
2727
}
2828

29-
type resultProcessor interface {
30-
Pairs(context.Context, *config.Config) []outputPair
31-
ProcessResult(context.Context, config.CombinedSettings, outputPair, *compiler.Result) error
29+
type ResultProcessor interface {
30+
Pairs(context.Context, *config.Config) []OutputPair
31+
ProcessResult(context.Context, config.CombinedSettings, OutputPair, *compiler.Result) error
3232
}
3333

34-
func Process(ctx context.Context, rp resultProcessor, dir, filename string, o *Options) error {
34+
func Process(ctx context.Context, rp ResultProcessor, dir, filename string, o *Options) error {
3535
e := o.Env
3636
stderr := o.Stderr
3737

@@ -55,7 +55,7 @@ func Process(ctx context.Context, rp resultProcessor, dir, filename string, o *O
5555
return processQuerySets(ctx, rp, inputs, o)
5656
}
5757

58-
func processQuerySets(ctx context.Context, rp resultProcessor, inputs *sourceFiles, o *Options) error {
58+
func processQuerySets(ctx context.Context, rp ResultProcessor, inputs *sourceFiles, o *Options) error {
5959
stderr := o.Stderr
6060
conf := inputs.Config
6161
dir := inputs.Dir

internal/cmd/push.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,17 @@ type pusher struct {
4646
results []*bundler.QuerySetArchive
4747
}
4848

49-
func (g *pusher) Pairs(ctx context.Context, conf *config.Config) []outputPair {
50-
var pairs []outputPair
49+
func (g *pusher) Pairs(ctx context.Context, conf *config.Config) []OutputPair {
50+
var pairs []OutputPair
5151
for _, sql := range conf.SQL {
52-
pairs = append(pairs, outputPair{
52+
pairs = append(pairs, OutputPair{
5353
SQL: sql,
5454
})
5555
}
5656
return pairs
5757
}
5858

59-
func (g *pusher) ProcessResult(ctx context.Context, combo config.CombinedSettings, sql outputPair, result *compiler.Result) error {
59+
func (g *pusher) ProcessResult(ctx context.Context, combo config.CombinedSettings, sql OutputPair, result *compiler.Result) error {
6060
req := codeGenRequest(result, combo)
6161
g.m.Lock()
6262
g.results = append(g.results, &bundler.QuerySetArchive{

internal/config/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ type SQL struct {
158158
// AnalyzerDatabase represents the database analyzer setting.
159159
// It can be a boolean (true/false) or the string "only" for database-only mode.
160160
type AnalyzerDatabase struct {
161-
value *bool // nil means not set, true/false for boolean values
162-
isOnly bool // true when set to "only"
161+
value *bool // nil means not set, true/false for boolean values
162+
isOnly bool // true when set to "only"
163163
}
164164

165165
// IsEnabled returns true if the database analyzer should be used.

0 commit comments

Comments
 (0)