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.
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]>
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
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
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")