11 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
Bugadinho 2b16f0cd14 Add tests for returning on SQL Server 2025-09-25 09:24:32 -03:00
Huan Du 18f7db8816 fix #211: Support clone (deep copy) in all builders 2025-09-17 16:19:09 +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 Du 827392d26d fix #186: use args in LIMIT and/or OFFSET expression 2025-01-26 15:06:21 +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
Huan Du b15ca56b4d refs #48 #49 #53: add new method SQL in all builders
All builders add a new method called SQL to enable us to add any
arbitrary SQL when building. It's quite useful when we are using some
kinds of extension syntax or add special comments in SQL.
2021-02-04 00:07:55 +08:00
Huan Du e121c6d3dd more tests 2017-12-28 01:56:44 +08:00
Huan Du 8193c41814 add tests and doc 2017-12-28 01:33:30 +08:00