Skip to content

style: rename _params and sb in generated code to clearer names #52

Description

@pageton

Summary

The SQL template renderer generates two local variables in every method body:

var sb strings.Builder
_params := make([]any, 0, N)

Two issues:

  1. _params — The leading _ is the Go blank identifier. Using it as a prefix for an actively-used variable is misleading. It suggests the variable is discarded when it's actually central to the method.
  2. sb — Too terse for a variable used across 20+ lines. A builder for a SQL query string deserves a clearer name.

Proposed

var buf strings.Builder
params := make([]any, 0, N)

Or alternatively query instead of buf since it's building a SQL query string.

Root Cause

  • internal/gen/sqlparser.goRenderSQLTemplate emits var sb strings.Builder and _params := make(...) literally
  • Also referenced in internal/gen/template.go method body templates

Affected

All generated output. The hardcoded names in the SQL template renderer need updating, plus any test golden files that match these strings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions