Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
a582287
chore(deps): bump actions/checkout from 4 to 5
dependabot[bot] Aug 11, 2025
6fd4719
Merge pull request #209 from si3nloong/dependabot/github_actions/dev/…
si3nloong Aug 19, 2025
a06b289
chore(deps): bump github.com/stretchr/testify from 1.10.0 to 1.11.0
dependabot[bot] Aug 26, 2025
0f8c6a0
Merge pull request #212 from si3nloong/dependabot/go_modules/dev/gith…
github-actions[bot] Aug 26, 2025
a1860a1
chore(deps): bump github.com/stretchr/testify from 1.11.0 to 1.11.1
dependabot[bot] Aug 27, 2025
6b3c029
Merge pull request #213 from si3nloong/dependabot/go_modules/dev/gith…
github-actions[bot] Aug 27, 2025
371ac99
chore(deps): bump github.com/spf13/cobra from 1.9.1 to 1.10.0
dependabot[bot] Sep 2, 2025
ec8604b
Merge pull request #214 from si3nloong/dependabot/go_modules/dev/gith…
github-actions[bot] Sep 2, 2025
e2528cc
chore(deps): bump github.com/spf13/cobra from 1.10.0 to 1.10.1
dependabot[bot] Sep 3, 2025
7b966ac
Merge pull request #215 from si3nloong/dependabot/go_modules/dev/gith…
github-actions[bot] Sep 3, 2025
8844179
chore(deps): bump actions/setup-go from 5 to 6
dependabot[bot] Sep 4, 2025
738cf72
Merge pull request #216 from si3nloong/dependabot/github_actions/dev/…
si3nloong Sep 8, 2025
0bc7940
chore(deps): bump github.com/jackc/pgx/v5 from 5.7.5 to 5.7.6
dependabot[bot] Sep 9, 2025
f7781c1
Merge pull request #217 from si3nloong/dependabot/go_modules/dev/gith…
github-actions[bot] Sep 9, 2025
f937f8b
chore(deps): bump golang.org/x/tools from 0.36.0 to 0.37.0
dependabot[bot] Sep 11, 2025
a6fce8f
Merge pull request #220 from si3nloong/dependabot/go_modules/dev/gola…
github-actions[bot] Sep 11, 2025
36c0682
Merge branch 'beta.1' of github.com-si3nloong:si3nloong/sqlgen into dev
si3nloong Nov 26, 2025
747e542
chore(deps): bump actions/setup-go from 5 to 6
dependabot[bot] Nov 27, 2025
ac469c9
Merge pull request #223 from si3nloong/dependabot/github_actions/dev/…
si3nloong Dec 9, 2025
f4ddd33
chore: drop 1.23
si3nloong Dec 9, 2025
54d16a1
chore(deps): bump goreleaser/goreleaser-action from 6 to 7
dependabot[bot] Feb 23, 2026
0893ceb
chore(deps): bump codecov/codecov-action from 5 to 6
dependabot[bot] Mar 27, 2026
fae7bce
chore(deps): bump dependabot/fetch-metadata from 2 to 3
dependabot[bot] Apr 9, 2026
60822d2
chore: change sequence
si3nloong Apr 13, 2026
32826ad
feat: generate anonymous functions
si3nloong Apr 13, 2026
ccb34d7
fix: generated codes
si3nloong Apr 16, 2026
7beba7b
chore: improve generated codes
si3nloong Apr 19, 2026
6d2e240
Merge pull request #226 from si3nloong/dependabot/github_actions/dev/…
si3nloong Apr 19, 2026
06fd806
Merge pull request #224 from si3nloong/dependabot/github_actions/dev/…
si3nloong Apr 19, 2026
dfce8f3
Merge pull request #225 from si3nloong/dependabot/github_actions/dev/…
si3nloong Apr 19, 2026
c8e2c76
fix: logical error on generated codes
si3nloong Apr 19, 2026
8b71ef1
fix: invalid SQL generated for `postgres`
si3nloong Apr 19, 2026
2487e3c
chore: rename normalized name and update go modules
si3nloong Apr 21, 2026
5a7f2ac
chore: improve generated codes
si3nloong Apr 21, 2026
4b09121
chore: remove go 1.24
si3nloong Apr 22, 2026
da2f293
fix: gh actions in windows machine
si3nloong Apr 23, 2026
6be826e
feat: support Go enum
si3nloong Apr 28, 2026
329998f
fix: Go enum bugs
si3nloong Apr 28, 2026
7070bf6
fix: generation bug
si3nloong Apr 28, 2026
7f81423
chore: update template codes
si3nloong Apr 30, 2026
97e5ecd
chore: update `UpsertOne`
si3nloong May 3, 2026
2c2c55c
feat: add `SetPK` functionality
si3nloong May 3, 2026
49d6bd4
fix: getter
si3nloong May 3, 2026
0826bd5
chore(deps): bump github.com/jaswdr/faker from 1.16.0 to 1.19.1
dependabot[bot] May 8, 2026
5d79c45
chore(deps): bump golang.org/x/tools from 0.37.0 to 0.44.0
dependabot[bot] May 8, 2026
fe1ab6c
chore(deps): bump github.com/goccy/go-yaml from 1.18.0 to 1.19.2
dependabot[bot] May 8, 2026
496ff5e
Merge pull request #228 from si3nloong/dependabot/go_modules/dev/gith…
github-actions[bot] May 8, 2026
2f3dfc3
Merge pull request #230 from si3nloong/dependabot/go_modules/dev/gola…
github-actions[bot] May 8, 2026
a489460
chore(deps): bump github.com/samber/lo from 1.51.0 to 1.53.0
dependabot[bot] May 8, 2026
d5b9eae
Merge pull request #231 from si3nloong/dependabot/go_modules/dev/gith…
github-actions[bot] May 8, 2026
25d5b11
chore(deps): bump github.com/Masterminds/semver/v3 from 3.4.0 to 3.5.0
dependabot[bot] May 8, 2026
5c97635
chore(deps): bump github.com/paulmach/orb from 0.11.1 to 0.13.0
dependabot[bot] May 8, 2026
afa24c2
Merge pull request #234 from si3nloong/dependabot/go_modules/dev/gith…
github-actions[bot] May 8, 2026
51c2262
Merge pull request #229 from si3nloong/dependabot/go_modules/dev/gith…
github-actions[bot] May 8, 2026
148f70e
Merge pull request #232 from si3nloong/dependabot/go_modules/dev/gith…
github-actions[bot] May 8, 2026
d81a2d6
chore(deps): bump github.com/golang-migrate/migrate/v4
dependabot[bot] May 8, 2026
fa0bb67
chore(deps): bump github.com/lib/pq from 1.10.9 to 1.12.3
dependabot[bot] May 8, 2026
90405a3
Merge pull request #235 from si3nloong/dependabot/go_modules/dev/gith…
github-actions[bot] May 8, 2026
810559a
Merge pull request #233 from si3nloong/dependabot/go_modules/dev/gith…
github-actions[bot] May 8, 2026
dbd55da
chore(deps): bump cloud.google.com/go from 0.121.6 to 0.123.0
dependabot[bot] May 11, 2026
3e73d87
chore(deps): bump github.com/mattn/go-sqlite3 from 1.14.22 to 1.14.44
dependabot[bot] May 11, 2026
038c97f
Merge pull request #236 from si3nloong/dependabot/go_modules/dev/clou…
github-actions[bot] May 11, 2026
9cb28ad
Merge pull request #238 from si3nloong/dependabot/go_modules/dev/gith…
github-actions[bot] May 11, 2026
c576d7a
chore(deps): bump github.com/go-playground/validator/v10
dependabot[bot] May 11, 2026
2e9c8e3
chore(deps): bump github.com/spf13/cobra from 1.10.1 to 1.10.2
dependabot[bot] May 11, 2026
2661cdf
Merge pull request #241 from si3nloong/dependabot/go_modules/dev/gith…
github-actions[bot] May 11, 2026
81c8bb0
Merge pull request #242 from si3nloong/dependabot/go_modules/dev/gith…
github-actions[bot] May 11, 2026
b68d69e
chore(deps): bump github.com/go-sql-driver/mysql from 1.9.3 to 1.10.0
dependabot[bot] May 11, 2026
5e15066
Merge pull request #239 from si3nloong/dependabot/go_modules/dev/gith…
github-actions[bot] May 11, 2026
8ab2727
chore(deps): bump github.com/gofrs/uuid/v5 from 5.0.0 to 5.4.0
dependabot[bot] May 11, 2026
a08e782
Merge pull request #240 from si3nloong/dependabot/go_modules/dev/gith…
github-actions[bot] May 11, 2026
7487da6
chore(deps): bump golang.org/x/tools from 0.44.0 to 0.45.0
dependabot[bot] May 11, 2026
988987d
Merge pull request #237 from si3nloong/dependabot/go_modules/dev/gola…
github-actions[bot] May 11, 2026
d623deb
fix: `path` and update `Date` and `Time` handling
si3nloong May 15, 2026
91a33c6
chore(deps): bump github.com/go-playground/validator/v10
dependabot[bot] Jun 2, 2026
91000df
Merge pull request #243 from si3nloong/dependabot/go_modules/dev/gith…
github-actions[bot] Jun 2, 2026
6a63d30
chore(deps): bump github.com/jackc/pgx/v5 from 5.9.2 to 5.10.0
dependabot[bot] Jun 4, 2026
9b86c26
Merge pull request #244 from si3nloong/dependabot/go_modules/dev/gith…
github-actions[bot] Jun 4, 2026
5931478
chore(deps): bump github.com/mattn/go-sqlite3 from 1.14.44 to 1.14.45
dependabot[bot] Jun 5, 2026
473df46
Merge pull request #245 from si3nloong/dependabot/go_modules/dev/gith…
github-actions[bot] Jun 5, 2026
51e70be
chore(deps): bump codecov/codecov-action from 6 to 7
dependabot[bot] Jun 8, 2026
46ebff2
chore(deps): bump golang.org/x/tools from 0.45.0 to 0.46.0
dependabot[bot] Jun 12, 2026
19ef072
Merge pull request #247 from si3nloong/dependabot/go_modules/dev/gola…
github-actions[bot] Jun 12, 2026
d56e8ca
chore(deps): bump github.com/mattn/go-sqlite3 from 1.14.45 to 1.14.46
dependabot[bot] Jun 18, 2026
5ea62b8
Merge pull request #248 from si3nloong/dependabot/go_modules/dev/gith…
github-actions[bot] Jun 18, 2026
fbd0dc6
Merge pull request #246 from si3nloong/dependabot/github_actions/dev/…
si3nloong Jun 19, 2026
c3912b1
chore(deps): bump github.com/mattn/go-sqlite3 from 1.14.46 to 1.14.47
dependabot[bot] Jun 22, 2026
eb0ba16
Merge pull request #250 from si3nloong/dependabot/go_modules/dev/gith…
github-actions[bot] Jun 22, 2026
6c76971
chore(deps): bump golang.org/x/tools from 0.46.0 to 0.47.0
dependabot[bot] Jun 26, 2026
c3ef82a
Merge pull request #251 from si3nloong/dependabot/go_modules/dev/gola…
github-actions[bot] Jun 26, 2026
2e26d68
chore(deps): bump golang.org/x/tools from 0.47.0 to 0.48.0
dependabot[bot] Jul 9, 2026
136e255
Merge pull request #252 from si3nloong/dependabot/go_modules/dev/gola…
github-actions[bot] Jul 9, 2026
f9d354d
chore(deps): bump github.com/mattn/go-sqlite3 from 1.14.47 to 1.14.48
dependabot[bot] Jul 13, 2026
911d836
Merge pull request #253 from si3nloong/dependabot/go_modules/dev/gith…
github-actions[bot] Jul 13, 2026
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/auto-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
steps:
- name: Dependabot metadata
id: dependabot_metadata
uses: dependabot/fetch-metadata@v2
uses: dependabot/fetch-metadata@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
# More assembly might be required: Docker logins, GPG, etc.
# It all depends on your needs.
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
uses: goreleaser/goreleaser-action@v7
with:
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser
Expand Down
14 changes: 8 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ jobs:
test:
strategy:
matrix:
# os: [ubuntu-latest, windows-latest]
os: [ubuntu-latest]
go: ["1.23", "1.24", "1.25"]
os: [ubuntu-latest, windows-latest]
# os: [ubuntu-latest]
go: ["1.25", "1.26"]
runs-on: ${{ matrix.os }}
continue-on-error: false
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v6

- name: Set up Go ${{ matrix.go }}
uses: actions/setup-go@v5
uses: actions/setup-go@v6
with:
go-version: ${{ matrix.go }}

Expand All @@ -26,10 +26,12 @@ jobs:
- name: Test
run: |
go test ./examples/testdata_test.go
go test -race -coverprofile=coverage.txt -covermode=atomic ./...
# Quote native command args with "=" so PowerShell on Windows
# does not split `coverage.txt` into a separate `.txt` token.
go test -race '-coverprofile=coverage.txt' '-covermode=atomic' ./...

- name: Codecov
uses: codecov/codecov-action@v5
uses: codecov/codecov-action@v7
with:
token: ${{secrets.CODECOV_TOKEN}}

Expand Down
41 changes: 18 additions & 23 deletions cmd/sqlgen/codegen/codegen.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,11 @@ import (
"log/slog"
"os"
"os/exec"
"path"
"path/filepath"
"regexp"
"strings"
"syscall"

"github.com/Masterminds/semver/v3"

"github.com/go-playground/validator/v10"
"github.com/samber/lo"
"github.com/si3nloong/sqlgen/cmd/sqlgen/codegen/dialect"
Expand All @@ -34,8 +31,8 @@ var (
`\`, `[\\/]`,
`/`, `[\\/]`,
)
nameRegex = regexp.MustCompile(`(?i)^[a-z]+[a-z0-9\_]*$`)
go121 = lo.Must1(semver.NewConstraint(">= 1.2.1"))
// nameRegex = regexp.MustCompile(`(?i)^[a-z]+[a-z0-9\_]*$`)
// go121 = lo.Must1(semver.NewConstraint(">= 1.2.1"))
// goTagRegexp = regexp.MustCompile(`(?i)^([a-z][a-z_]*[a-z])(\:(\w+))?$`)
// sqlFuncRegexp = regexp.MustCompile(`(?i)\s*(\w+\()(\w+\s*\,\s*)?(\{\})(\s*\,\s*\w+)?(\))\s*`)
)
Expand Down Expand Up @@ -153,17 +150,17 @@ func Walk(cfg *Config, walkFunc WalkFunc) error {
}

func Generate(c *Config) error {
vldr := validator.New()
if err := vldr.Struct(c); err != nil {
return err
}
// vldr := validator.New()
// if err := vldr.Struct(c); err != nil {
// return err
// }

cfg := DefaultConfig()
if c != nil {
cfg = cfg.Merge(c)
}

dialect, ok := dialect.GetDialect((string)(cfg.Driver))
dialect, ok := dialect.GetDialect(string(cfg.Driver))
if !ok {
return fmt.Errorf("sqlgen: missing dialect, please register dialect %q", cfg.Driver)
}
Expand All @@ -182,6 +179,7 @@ func Generate(c *Config) error {
// Resolve every source provided
for len(sources) > 0 {
srcDir = strings.TrimSpace(sources[0])
sources = sources[1:]
if srcDir == "" {
return fmt.Errorf("sqlgen: source directory %q is empty path", srcDir)
}
Expand All @@ -200,7 +198,7 @@ func Generate(c *Config) error {
srcDir = srcDir + ".go"
}

slog.Info("Processing", "dir", srcDir)
slog.Info(fmt.Sprintf("Processing %q", srcDir))

// File: examples/testdata/test.go
// Folder: examples/testdata
Expand Down Expand Up @@ -242,7 +240,7 @@ func Generate(c *Config) error {
fi, err := os.Stat(srcDir)
// If the file or folder not exists, we skip!
if os.IsNotExist(err) {
goto nextSrc
continue
} else if err != nil {
return err
}
Expand All @@ -263,9 +261,6 @@ func Generate(c *Config) error {
if err := parseGoPackage(generator, rootDir, dirs, matcher); err != nil {
return err
}

nextSrc:
sources = sources[1:]
}

if cfg.Database != nil {
Expand Down Expand Up @@ -314,16 +309,16 @@ func parseGoPackage(
rename := g.config.RenameFunc()

for len(dirs) > 0 {
dir = path.Join(rootDir, dirs[0])
dir = filepath.Join(rootDir, dirs[0])
dirs = dirs[1:]

// Sometimes user might place db destination in the source as well
// In this situation, we're not process the folder, we will skip it
// if the file is exists in db folder
pwd := fileutil.Getpwd()
if idx := lo.IndexOf([]string{
path.Join(pwd, g.config.Database.Dir),
path.Join(pwd, g.config.Database.Operator.Dir),
filepath.Join(pwd, g.config.Database.Dir),
filepath.Join(pwd, g.config.Database.Operator.Dir),
}, dir); idx >= 0 {
continue
}
Expand All @@ -334,7 +329,7 @@ func parseGoPackage(
continue
}

filename = path.Join(dir, g.config.Exec.Filename)
filename = filepath.Join(dir, g.config.Exec.Filename)
// Unlink the generated file, ignore the error
_ = syscall.Unlink(filename)

Expand Down Expand Up @@ -378,16 +373,16 @@ func (g *Generator) parseGoPackageV2(
rename := g.config.RenameFunc()

for len(dirs) > 0 {
dir = path.Join(rootDir, dirs[0])
dir = filepath.Join(rootDir, dirs[0])
dirs = dirs[1:]

// Sometimes user might place db destination in the source as well
// In this situation, we're not process the folder, we will skip it
// if the file is exists in db folder
pwd := fileutil.Getpwd()
if idx := lo.IndexOf([]string{
path.Join(pwd, g.config.Database.Dir),
path.Join(pwd, g.config.Database.Operator.Dir),
filepath.Join(pwd, g.config.Database.Dir),
filepath.Join(pwd, g.config.Database.Operator.Dir),
}, dir); idx >= 0 {
continue
}
Expand All @@ -398,7 +393,7 @@ func (g *Generator) parseGoPackageV2(
continue
}

filename = path.Join(dir, g.config.Exec.Filename)
filename = filepath.Join(dir, g.config.Exec.Filename)
// Unlink the generated file, ignore the error
_ = syscall.Unlink(filename)

Expand Down
Loading
Loading