Skip to content

fix: typo sql tempalte and minor style issues in internal/gen #51

Description

@pageton

Summary

A few small issues in internal/gen/:

1. Typo in panic message

internal/gen/sqlparser.go:90:

panic(fmt.Sprintf("unsupported func %q in sql tempalte\n", f.Name))

tempaltetemplate

2. Abbreviated variable name pth

internal/gen/generator.go:110:

for pth, file := range g.Files {

pth is an abbreviation that saves 1 character over path. In a 30-line block it adds no value. Use path or filePath for readability.

3. Operator precedence ambiguity

internal/gen/generator.go:630:

if method.SQL.Where == "" && method.SQL.Select == "" || method.SQL.Raw != "" {

The || binds loosely. Add explicit parens to make intent clear:

if (method.SQL.Where == "" && method.SQL.Select == "") || method.SQL.Raw != "" {

4. Verbose local in sqlparser.go

internal/gen/sqlparser.go:326-343:

paramsCount := 0  // used in 4 adjacent lines
codes := []string{}  // used in 4 adjacent lines

Shorter names like count and lines would suffice for the narrow scope.

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