303 Commits
Author SHA1 Message Date
zooqueen f17ed0bb2d deps: declare the go the tests already need
go.mod said go 1.18, so the runner fetched 1.18.10 and the package would not
even set up:

  select_fuzz_test.go:7:2: package slices is not in GOROOT
  FAIL github.com/hanzoai/sqlbuilder [setup failed]

slices arrived in 1.21 and select_fuzz_test.go imports it. 1.21 is the lowest
version that compiles this, which keeps the module usable by as many consumers
as possible — nothing here needs anything newer.

go build ./... and go test ./... both clean.
2026-08-10 22:11:13 -07:00
zeekayandHanzo Dev c1b2406ef8 ci: canonical pair — hanzo.yml + forge caller
github.com has no runner for hanzo-build-linux-amd64, so a caller under
.github/workflows is a gate that can never be scheduled. This is the ~7-line
caller on the plane that can (git.hanzo.ai git-runner fleet), pinned @v1.

Co-authored-by: Hanzo Dev <[email protected]>
2026-08-06 02:39:05 -07:00
zeekay 74627ec1a2 Fork huandu/go-sqlbuilder v1.39.1 to hanzoai/sqlbuilder; debrand ClickHouse flavor -> Datastore
- go.mod module path -> github.com/hanzoai/sqlbuilder (package name kept: sqlbuilder)
- Rename exported Flavor constant ClickHouse -> Datastore (same iota ordinal 6,
  behavior byte-identical): const decl, all case labels (Interpolate/Quote/
  PrepareInsertIgnore/args/select/union), Flavor.String() literal "ClickHouse"
  -> "Datastore", and the name<->flavor test map.
- Rename unexported dialect helper clickhouseInterpolate -> datastoreInterpolate.
- Rename example ExampleInsertBuilder_insertIgnore_clickhouse -> _datastore.
- Update tests + README flavor list to Datastore.
- Keep upstream MIT LICENSE; add NOTICE recording the fork + rename.

Dialect SQL output unchanged; only the identifier is renamed.
v1.39.2
2026-07-12 18:00:41 -07:00
Huan DuandGitHub 2f870c8bce Merge pull request #231 from zhangyongding/chore-oralce-select-offset-fetch
change the Oracle select to use OFFSET...FETCH
2026-02-10 17:37:41 +08:00
3f3e5aa6de Update select.go
Co-authored-by: Hanzo Dev <[email protected]>
2026-01-27 08:16:05 +08:00
zhangyongding 18d53180f6 change the Oracle select to use OFFSET...FETCH 2026-01-22 08:35:52 +08:00
Huan DuandGitHub 74632b3aec Merge pull request #230 from stvnkiss/master
Add From support for UpdateBuilder
2026-01-20 15:30:37 +08:00
Istvan Kiss c05738d4d6 Merge remote-tracking branch 'origin/master' into frok/master
# Conflicts:
#	update.go
2026-01-20 08:19:30 +01:00
Huan Du 053369bda3 fix #229: update doc on Where to avoid confusion 2026-01-20 11:48:29 +08:00
Istvan Kiss 3550ec0bd2 document UpdateBuilder.From in README.md 2026-01-19 16:08:30 +01:00
Istvan Kiss 7c3be4718b test From on UpdateBuilder 2026-01-19 16:08:30 +01:00
Istvan Kiss cc4c727a83 added From support for UpdateBuilder 2026-01-19 16:08:30 +01:00
Huan DuandGitHub 22ee7f6fa6 Merge pull request #228 from shoriwe/fix/sqlite-strings
fix #227: sqlite: string interpolation incorrectly uses backslash escapes
2025-12-30 15:24:20 +08:00
Antonio 187aaab065 fix: removed comments 2025-12-29 11:36:09 -04:00
Antonio 6d84952db1 test: make all tests pass by resolving to correct SQLite syntax 2025-12-29 11:33:43 -04:00
Huan Du af5ffafd92 fix #223: mark OrderBy as "not recommended" rather than deprecated 2025-12-29 11:20:02 +08:00
Huan DuandGitHub ace5638571 Merge pull request #226 from shoriwe/fix/improve-error-context
fix #225: improve error-msg context for unsupported types during interpolation
2025-12-29 10:44:45 +08:00
Antonio e7492f64ba fix: improved msg during byte slice 2025-12-25 14:44:41 -04:00
Antonio ca38f3ebc3 fix: factually correct escpaing in sqlite 2025-12-25 14:19:30 -04:00
Antonio 12ff5ab864 fix: sqlite single quote interpolations 2025-12-25 13:13:08 -04:00
Antonio a3e890bc83 fix: improve error-msg context for unsupported types during interpolation 2025-12-25 12:44:30 -04:00
Huan DuandGitHub 65792c9a9b Merge pull request #222 from zhangyongding/fix-oralce-limit
fix oracle limit bug
2025-10-24 12:23:49 +08:00
zhangyongding f8440f9506 fix oracle limit bug 2025-10-20 18:13:44 +08:00
Huan Du f3798970f7 Add nested JOIN example to README and tests
Add documentation and test example demonstrating how to use BuilderAs
to create nested JOIN queries. This is useful when joining with filtered
or transformed datasets.

fix #217
2025-10-10 16:27:13 +08:00
Huan Du 6db1108ec3 Add OrderByAsc and OrderByDesc methods to all builders
Implement new OrderByAsc(col) and OrderByDesc(col) methods for
SelectBuilder, UnionBuilder, UpdateBuilder, and DeleteBuilder. These
methods allow chaining multiple ORDER BY columns with different sort
directions, addressing the limitation where the old OrderBy/Asc/Desc
pattern could only apply a single direction to all columns.

Key changes:
- Add OrderByAsc(col string) and OrderByDesc(col string) to all four builders
- Each method appends the column with explicit ASC/DESC suffix
- Support chaining for complex ordering: OrderByDesc("score").OrderByAsc("name")
- Deprecate OrderBy/Asc/Desc methods with clear migration guidance
- Add comprehensive tests (TestSelectBuilder_OrderByAscDesc)
- Add example functions demonstrating usage
- Update all existing examples to use new API
- Update README.md with new "Build ORDER BY clause" section

This design is inspired by MyBatis-Plus and provides a more intuitive
and flexible API for handling multiple ORDER BY columns with different
sorting directions.

fix #214
2025-10-10 16:13:30 +08:00
Huan DuandGitHub f3199b6b4e Merge pull request #220 from Bugadinho/return-sqlserver
Implement returning method on SQL Server
2025-10-10 15:37:44 +08:00
Bugadinho 2b16f0cd14 Add tests for returning on SQL Server 2025-09-25 09:24:32 -03:00
Bugadinho 0542598588 Add returning support on SQL Server 2025-09-25 09:24:16 -03:00
Bugadinho 7853a4a665 Add WriteStringsPrefixed 2025-09-25 09:23:11 -03:00
Huan DuandGitHub 2276b9fee0 Merge pull request #218 from huandu/feature/copy-builder
Fix #211: Support clone (deep copy) in all builders
2025-09-17 19:46:36 +08:00
Huan Du a8e00376cd add fuzz test for SelectBuilder.Clone 2025-09-17 19:44:51 +08:00
Huan Du 4907a9ee13 fix lint warning 2025-09-17 16:31:21 +08:00
Huan Du 7bca6a9650 update readme for CLone 2025-09-17 16:28:12 +08:00
Huan Du 18f7db8816 fix #211: Support clone (deep copy) in all builders 2025-09-17 16:19:09 +08:00
Huan DuandGitHub 88a656d237 Merge pull request #216 from zhangyongding/union-support-limit
fix: union limit
2025-09-17 13:48:52 +08:00
zhangyongding fb0b217e0f fix: union limit 2025-09-17 10:24:20 +08:00
Huan Du e47fcc5fb9 fix #213 support typed nil in interpolation 2025-08-11 18:32:23 +08:00
Huan DuandGitHub 6587b1a288 Merge pull request #212 from huandu/feature/returning-clause-issue-210
feat: implement Returning method for UpdateBuilder and DeleteBuilder
2025-07-25 11:07:39 +08:00
Huan Du 8e5ccbbee2 feat: implement Returning method for UpdateBuilder and DeleteBuilder
Fixes #210

This commit adds the Returning method to both UpdateBuilder and DeleteBuilder,
following the same implementation pattern as InsertBuilder.

Changes:
- Add returning field to UpdateBuilder and DeleteBuilder structs
- Add updateMarkerAfterReturning and deleteMarkerAfterReturning markers
- Implement Returning methods for both builders
- Add RETURNING clause support for PostgreSQL and SQLite flavors
- Add comprehensive test coverage including:
  - Basic functionality tests
  - Flavor-specific behavior tests
  - Edge cases (empty, single, multiple columns)
  - Complex scenarios (ORDER BY, LIMIT, CTE)
  - SQL injection compatibility
  - Method chaining validation

The RETURNING clause is properly positioned after LIMIT and is ignored
for database flavors that don't support it (MySQL, SQL Server, CQL,
ClickHouse, Presto).

Example usage:
  ub := Update("users").Set("name = ?", "John").Where("id = ?", 1).Returning("id", "updated_at")
  db := DeleteFrom("users").Where("status = ?", "inactive").Returning("id", "deleted_at")
2025-07-24 16:01:37 +00:00
Huan DuandGitHub b1fd2b84b5 Merge pull request #204 from edznux-dd/nil-pointer-deref
[bugfix] Nil pointer deref
2025-07-06 18:55:09 +08:00
Huan DuandGitHub 600a50b33f Merge pull request #207 from edznux-dd/add-fuzzer
Add a fuzz harness for Select
2025-07-06 18:54:44 +08:00
Edouard Schweisguth 6f2ca59f11 Add nil check before executing functions 2025-06-25 11:36:08 +02:00
Edouard Schweisguth 542af0bd67 Add nil check regression for BuildWithFlavor 2025-06-25 11:35:45 +02:00
Edouard Schweisguth a0cb9722f3 Add regression test 2025-06-25 11:27:06 +02:00
Edouard Schweisguth 19f7503839 Add a fuzz harness for Select 2025-06-25 11:24:11 +02:00
Huan Du e9d31b7960 fix #200: PostgreSQL InsertIgnoreInto with subquery doesn't append ON CONFLICT DO NOTHING 2025-06-13 01:05:33 +08:00
Huan Du d882448972 fix #202: NotIn with empty values builds "0 = 0" 2025-06-13 00:58:47 +08:00
Huan Du 8ed4b5374f fix #192 Add new flavor Doris 2025-03-20 19:05:19 +08:00
Huan DuandGitHub 5afad98d5c Merge pull request #196 from barweiss/fix-presto-limit-and-offset-order
Fix #195 the order of LIMIT and OFFSET clauses when using the Presto flavor
2025-03-20 18:28:01 +08:00
Bar Weiss 0f5ba50c2c Add some in-code documentation 2025-03-20 10:47:05 +02:00