12 Commits
Author SHA1 Message Date
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.
2026-07-12 18:00:41 -07: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 Du 18f7db8816 fix #211: Support clone (deep copy) in all builders 2025-09-17 16:19:09 +08:00
Huan Du bbd370c39c fix #184: fix SQL syntax error in WITH ... UPDATE ... FROM 2024-12-05 13:00:55 +08:00
Huan Du e3eef72bb4 refs #176: Automatically ref names of CTETables in DELETE and UPDATE statement 2024-11-02 23:03:02 +08:00
Vasily Rodionov 98718aad2d new: Added Flavor method to Builder interface 2024-10-31 15:23:25 +05:00
Vasily Rodionov b28a583417 new: flavor getters 2024-10-30 20:39:31 +05:00
Huan Du cd1b266513 fix #163: CTE API refactory; see issue for details 2024-09-09 01:52:01 +08:00
Arik Kfir cacc5a5636 feature #161: add support for recursive CTEs
This change adds support for recursive CTEs by introducing the
`WithRecursive` method, which builds a `WITH RECURSIVE` clause.
2024-08-21 17:14:38 +03:00
Huan Du e8528206c0 fix: #160 SelectBuilder.With appends table names to FROM 2024-08-04 20:29:26 +08:00
Huan Du 85be89ace1 support multiple tables in a WITH clause 2024-07-24 16:54:41 +08:00
Huan Du 75c6f8c1e4 implement CTEBuilder 2024-07-06 23:58:26 +08:00