Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
go-version: '1.25.0'
go-version: '1.26.0'
- name: install ./...
run: go build ./...
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-kotlin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
go-version: '1.24.1'
go-version: '1.26.0'
- name: install ./...
run: go install ./...
- uses: actions/checkout@v6
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
go-version: '1.24.1'
go-version: '1.26.0'
- name: install ./...
run: go install ./...
- uses: actions/checkout@v6
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-typescript.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
go-version: '1.24.1'
go-version: '1.26.0'
- name: install ./...
run: go install ./...
- uses: actions/checkout@v6
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
go-version: '1.25.0'
go-version: '1.26.0'
- run: go build ./...
env:
CGO_ENABLED: "0"
Expand All @@ -28,7 +28,7 @@ jobs:
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
go-version: '1.25.0'
go-version: '1.26.0'

- name: install gotestsum
run: go install gotest.tools/gotestsum@latest
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/sqlc
/.idea/
__pycache__
.DS_Store
Expand Down
16 changes: 12 additions & 4 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,21 @@ This document provides essential information for working with the sqlc codebase,

### Prerequisites

- **Go 1.25.0+** - Required for building and testing
- **Go 1.26.0+** - Required for building and testing
- **Docker & Docker Compose** - Required for integration tests with databases (local development)
- **Git** - For version control

## Claude Code Remote Environment Setup

When running in the Claude Code remote environment (or any environment without Docker), you can install PostgreSQL and MySQL natively. The test framework automatically detects and uses native database installations.

### Network Proxy (Pre-configured)

The Claude Code remote environment routes outbound traffic through an HTTP proxy via the `HTTP_PROXY` and `HTTPS_PROXY` environment variables. **Go module operations (`go mod tidy`, `go mod download`, `go get`, etc.) work automatically** because Go's toolchain respects these variables. No extra configuration is needed for the Go module proxy (`proxy.golang.org`) or checksum database (`sum.golang.org`).

### Step 1: Configure apt Proxy (Required in Remote Environment)

The Claude Code remote environment requires an HTTP proxy for apt. Configure it:
The apt package manager needs its own proxy configuration since it does not read `HTTP_PROXY`:

```bash
bash -c 'echo "Acquire::http::Proxy \"$http_proxy\";"' | sudo tee /etc/apt/apt.conf.d/99proxy
Expand Down Expand Up @@ -306,9 +310,13 @@ POSTGRESQL_SERVER_URI="postgres://postgres:mysecretpassword@localhost:5432/postg

## Common Issues & Solutions

### Network Connectivity Issues
### Network Connectivity / Go Module Proxy Issues

In the Claude Code remote environment, Go module fetching works automatically via the `HTTP_PROXY`/`HTTPS_PROXY` environment variables. If you see errors about `storage.googleapis.com` or `proxy.golang.org`:

If you see errors about `storage.googleapis.com`, the Go proxy may be unreachable. Tests may still pass for packages that don't require network dependencies.
1. **Verify proxy vars are set:** `echo $HTTP_PROXY` (should be non-empty in the remote environment)
2. **Test connectivity:** `go mod download 2>&1 | head` to check for errors
3. **If proxy is not set** (e.g., local development without Docker), Go will try to reach `proxy.golang.org` directly, which requires internet access

### Test Timeouts

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# STEP 1: Build sqlc
FROM golang:1.25.5 AS builder
FROM golang:1.26.0 AS builder

COPY . /workspace
WORKDIR /workspace
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/sqlc-dev/sqlc

go 1.24.7
go 1.26.0

require (
github.com/antlr4-go/antlr/v4 v4.13.1
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ var initCmd = &cobra.Command{
if err != nil {
return err
}
var yamlConfig interface{}
var yamlConfig any
if useV1 {
yamlConfig = config.V1GenerateSettings{Version: "1"}
} else {
Expand Down
1 change: 0 additions & 1 deletion internal/cmd/createdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ func CreateDB(ctx context.Context, dir, filename, querySetName string, o *Option
var queryset *config.SQL
var count int
for _, sql := range conf.SQL {
sql := sql
if querySetName != "" && sql.Name != querySetName {
continue
}
Expand Down
20 changes: 10 additions & 10 deletions internal/codegen/golang/field.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,23 +97,23 @@ func toPascalCase(s string) string {
}

func toCamelInitCase(name string, initUpper bool) string {
out := ""
var out strings.Builder
for i, p := range strings.Split(name, "_") {
if !initUpper && i == 0 {
out += p
out.WriteString(p)
continue
}
if p == "id" {
out += "ID"
out.WriteString("ID")
} else {
out += strings.Title(p)
out.WriteString(strings.Title(p))
}
}
return out
return out.String()
}

func toJsonCamelCase(name string, idUppercase bool) string {
out := ""
var out strings.Builder
idStr := "Id"

if idUppercase {
Expand All @@ -122,16 +122,16 @@ func toJsonCamelCase(name string, idUppercase bool) string {

for i, p := range strings.Split(name, "_") {
if i == 0 {
out += p
out.WriteString(p)
continue
}
if p == "id" {
out += idStr
out.WriteString(idStr)
} else {
out += strings.Title(p)
out.WriteString(strings.Title(p))
}
}
return out
return out.String()
}

func toLowerCase(str string) string {
Expand Down
7 changes: 3 additions & 4 deletions internal/codegen/golang/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"errors"
"fmt"
"go/format"
"slices"
"strings"
"text/template"

Expand Down Expand Up @@ -344,10 +345,8 @@ func usesCopyFrom(queries []Query) bool {

func usesBatch(queries []Query) bool {
for _, q := range queries {
for _, cmd := range []string{metadata.CmdBatchExec, metadata.CmdBatchMany, metadata.CmdBatchOne} {
if q.Cmd == cmd {
return true
}
if slices.Contains([]string{metadata.CmdBatchExec, metadata.CmdBatchMany, metadata.CmdBatchOne}, q.Cmd) {
return true
}
}
return false
Expand Down
9 changes: 3 additions & 6 deletions internal/codegen/golang/go_type.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package golang

import (
"maps"
"strings"

"github.com/sqlc-dev/sqlc/internal/codegen/golang/opts"
Expand All @@ -15,9 +16,7 @@ func addExtraGoStructTags(tags map[string]string, req *plugin.GenerateRequest, o
continue
}
if override.MatchesColumn(col) {
for k, v := range oride.GoType.StructTags {
tags[k] = v
}
maps.Copy(tags, oride.GoType.StructTags)
continue
}
if !override.Matches(col.Table, req.Catalog.DefaultSchema) {
Expand All @@ -33,9 +32,7 @@ func addExtraGoStructTags(tags map[string]string, req *plugin.GenerateRequest, o
continue
}
// Add the extra tags.
for k, v := range oride.GoType.StructTags {
tags[k] = v
}
maps.Copy(tags, oride.GoType.StructTags)
}
}

Expand Down
2 changes: 1 addition & 1 deletion internal/codegen/golang/opts/go_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (o *GoType) UnmarshalJSON(data []byte) error {
return nil
}

func (o *GoType) UnmarshalYAML(unmarshal func(interface{}) error) error {
func (o *GoType) UnmarshalYAML(unmarshal func(any) error) error {
var spec string
if err := unmarshal(&spec); err == nil {
*o = GoType{Spec: spec}
Expand Down
10 changes: 5 additions & 5 deletions internal/codegen/golang/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,17 +168,17 @@ func paramName(p *plugin.Parameter) string {
}

func argName(name string) string {
out := ""
var out strings.Builder
for i, p := range strings.Split(name, "_") {
if i == 0 {
out += strings.ToLower(p)
out.WriteString(strings.ToLower(p))
} else if p == "id" {
out += "ID"
out.WriteString("ID")
} else {
out += strings.Title(p)
out.WriteString(strings.Title(p))
}
}
return out
return out.String()
}

func buildQueries(req *plugin.GenerateRequest, options *opts.Options, structs []Struct) ([]Query, error) {
Expand Down
2 changes: 1 addition & 1 deletion internal/codegen/golang/struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func StructName(name string, options *opts.Options) string {
return rune('_')
}, name)

for _, p := range strings.Split(name, "_") {
for p := range strings.SplitSeq(name, "_") {
if _, found := options.InitialismsMap[p]; found {
out += strings.ToUpper(p)
} else {
Expand Down
1 change: 0 additions & 1 deletion internal/compiler/output_columns.go
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,6 @@ func (c *Compiler) sourceTables(qc *QueryCatalog, node ast.Node) ([]*Table, erro

var tables []*Table
for _, item := range list.Items {
item := item
switch n := item.(type) {

case *ast.RangeFunction:
Expand Down
10 changes: 5 additions & 5 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (p *Paths) UnmarshalJSON(data []byte) error {
return nil
}

func (p *Paths) UnmarshalYAML(unmarshal func(interface{}) error) error {
func (p *Paths) UnmarshalYAML(unmarshal func(any) error) error {
out := []string{}
if sliceErr := unmarshal(&out); sliceErr != nil {
var ele string
Expand All @@ -61,7 +61,7 @@ type Config struct {
Cloud Cloud `json:"cloud" yaml:"cloud"`
Servers []Server `json:"servers" yaml:"servers"`
SQL []SQL `json:"sql" yaml:"sql"`
Overrides Overrides `json:"overrides,omitempty" yaml:"overrides"`
Overrides Overrides `json:"overrides" yaml:"overrides"`
Plugins []Plugin `json:"plugins" yaml:"plugins"`
Rules []Rule `json:"rules" yaml:"rules"`
Options map[string]yaml.Node `json:"options" yaml:"options"`
Expand Down Expand Up @@ -125,8 +125,8 @@ type SQL struct {
// AnalyzerDatabase represents the database analyzer setting.
// It can be a boolean (true/false) or the string "only" for database-only mode.
type AnalyzerDatabase struct {
value *bool // nil means not set, true/false for boolean values
isOnly bool // true when set to "only"
value *bool // nil means not set, true/false for boolean values
isOnly bool // true when set to "only"
}

// IsEnabled returns true if the database analyzer should be used.
Expand Down Expand Up @@ -166,7 +166,7 @@ func (a *AnalyzerDatabase) UnmarshalJSON(data []byte) error {
return errors.New("analyzer.database must be true, false, or \"only\"")
}

func (a *AnalyzerDatabase) UnmarshalYAML(unmarshal func(interface{}) error) error {
func (a *AnalyzerDatabase) UnmarshalYAML(unmarshal func(any) error) error {
// Try to unmarshal as boolean first
var b bool
if err := unmarshal(&b); err == nil {
Expand Down
6 changes: 3 additions & 3 deletions internal/config/convert/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import (
"gopkg.in/yaml.v3"
)

func gen(n *yaml.Node) (interface{}, error) {
func gen(n *yaml.Node) (any, error) {
switch n.Kind {

case yaml.MappingNode:
nn := map[string]interface{}{}
nn := map[string]any{}
for i, _ := range n.Content {
if i%2 == 0 {
k := n.Content[i]
Expand All @@ -26,7 +26,7 @@ func gen(n *yaml.Node) (interface{}, error) {
return nn, nil

case yaml.SequenceNode:
nn := []interface{}{}
nn := []any{}
for i, _ := range n.Content {
v, err := gen(n.Content[i])
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/dbmanager/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (m *ManagedClient) CreateDatabase(ctx context.Context, req *CreateDatabaseR
uri.Path = "/" + name

key := uri.String()
_, err, _ = flight.Do(key, func() (interface{}, error) {
_, err, _ = flight.Do(key, func() (any, error) {
// TODO: Use a parameterized query
row := pool.QueryRow(ctx,
fmt.Sprintf(`SELECT datname FROM pg_database WHERE datname = '%s'`, name))
Expand Down
2 changes: 1 addition & 1 deletion internal/debug/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func init() {
}
}

func Dump(n ...interface{}) {
func Dump(n ...any) {
if Active {
spew.Dump(n)
}
Expand Down
2 changes: 0 additions & 2 deletions internal/endtoend/ddl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (

func TestValidSchema(t *testing.T) {
for _, replay := range FindTests(t, "testdata", "base") {
replay := replay // https://golang.org/doc/faq#closures_and_goroutines

if replay.Exec != nil {
if replay.Exec.Meta.InvalidSchema {
Expand All @@ -32,7 +31,6 @@ func TestValidSchema(t *testing.T) {
}

for j, pkg := range conf.SQL {
j, pkg := j, pkg
switch pkg.Engine {
case config.EnginePostgreSQL:
// pass
Expand Down
3 changes: 0 additions & 3 deletions internal/endtoend/endtoend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,6 @@ func TestReplay(t *testing.T) {
}

for name, testctx := range contexts {
name := name
testctx := testctx

if !testctx.Enabled() {
continue
Expand Down Expand Up @@ -354,7 +352,6 @@ func cmpDirectory(t *testing.T, dir string, actual map[string]string) {
if !cmp.Equal(expected, actual, opts...) {
t.Errorf("%s contents differ", dir)
for name, contents := range expected {
name := name
if actual[name] == "" {
t.Errorf("%s is empty", name)
return
Expand Down
Loading
Loading