71 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
Istvan Kiss 3550ec0bd2 document UpdateBuilder.From in README.md 2026-01-19 16:08:30 +01: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 Du 7bca6a9650 update readme for CLone 2025-09-17 16:28:12 +08:00
Huan Du 827392d26d fix #186: use args in LIMIT and/or OFFSET expression 2025-01-26 15:06:21 +08:00
Huan Du e979adcd4a update doc for IsDistinctFrom and IsNotDistinctFrom 2024-09-23 22:06:35 +08:00
Huan Du 19835c7b14 update docs in README and godoc 2024-09-10 17:22:08 +08:00
Huan DuandGitHub b6974302a0 Merge pull request #159 from abanoub-fathy/add-ILIKE-helper-method
Add ilike helper method
2024-07-26 12:22:41 +08:00
Abanoub Fathy 7c5bcc0430 update readme file to add Cond.ILIKE 2024-07-10 02:59:56 +03:00
Huan Du 75c6f8c1e4 implement CTEBuilder 2024-07-06 23:58:26 +08:00
Huan Du 76f1e16370 add sample to show how to build JOIN with Struct 2024-04-24 02:52:38 +08:00
Huan Du 64a2aa1d63 update doc to be clear about the goal of this package 2024-04-15 11:44:51 +08:00
Huan Du 96e64e9b7d feature: new builder WhereClause dedicated for WHERE 2024-04-13 23:32:24 +08:00
Huan Du e0fd349ac7 update doc and tests for oracle flavor 2023-11-04 14:33:25 +08:00
Huan Du 2364e7835b add doc 2023-07-22 22:54:09 +08:00
Huan DuandGitHub cb38c02175 Merge pull request #102 from huandu/feature-more-cond
fix #100 Add EXISTS/NOT EXISTS/ANY/SOME/ALL in `Cond`
2023-04-01 16:57:49 +08:00
Huan Du fa218b8b11 update sample output in README 2023-04-01 16:48:19 +08:00
Huan Du eb96df9e68 refs #100 add EXISTS/NOT EXISTS/ANY/SOME/ALL in Cond 2023-04-01 16:43:22 +08:00
Huan Du ce1b345ef8 update doc 2023-03-27 23:31:03 +08:00
Huan Du 0b1c445a5c refs #98 add new flavor Presto 2023-03-27 23:17:33 +08:00
Huan Du ca5bb168f8 update test cases and examples for better coverage 2023-02-27 10:13:49 +08:00
Huan Du 42130d3b3a refs #60. more flexibility to filter fields with WithTag and WithoutTag in Struct 2023-02-27 00:59:49 +08:00
Huan Du 59650fe906 update readme and format code 2023-01-12 17:08:08 +08:00
Spencer Connaughton 8880301f5b Merge remote-tracking branch 'upstream/master'
# Conflicts:
#	README.md
#	args.go
#	flavor.go
#	insert_test.go
#	interpolate.go
#	interpolate_test.go
#	select_test.go
#	struct.go
#	struct_test.go
2023-01-05 10:19:05 -05:00
csuzhang 67863e4274 fix readme 2022-12-12 17:46:29 +08:00
39a4b2509b Merge remote-tracking branch 'upstream/master' (#2)
* ignore unexported fields that are not embedded structs

* fix #74 [BREAKING CHANGE] Select#GroupBy and Select#OrderBy behavior change.

Previous, GroupBy and OrderBy only keep the columns in the last call. Now, all columns are kept.

* fix #75 add Struct#Columns/ColumnsForTag and Struct#Values/ValuesForTag

* remove a call to StructField.IsExported as it is not in go1.13

* refs #78 add new `fieldas` tag to set AS name for SELECT

* update docs

* fix #81 refactory struct field parser to make fieldas correct in all cases

* Add Gitter badge

* Fix insert ignore for postgres and sqlite.

* fix test

Co-authored-by: Michał Dobaczewski <[email protected]>
Co-authored-by: Huan Du <[email protected]>
Co-authored-by: The Gitter Badger <[email protected]>
Co-authored-by: Zhong Ren <[email protected]>
2022-11-30 10:57:35 -05:00
The Gitter Badger 826531124f Add Gitter badge 2022-09-09 02:46:28 +00:00
Spencer ConnaughtonandGitHub 0f54cd520c Add CQL support (#1)
* Add CQL flavor.

* Add support for CQL argument compilation.

* Adopt substests for interpolation tests.

* Add support for CQL interpolation.

* Add support for CQL blobs.

https://docs.datastax.com/en/cql-oss/3.x/cql/cql_reference/blob_r.html

* Add CQL timestamp interpolation support.

https://docs.datastax.com/en/cql-oss/3.x/cql/cql_reference/timestamp_type_r.html

* Add builder test for CQL.

* Add support for the NOW function.

https://docs.datastax.com/en/cql-oss/3.3/cql/cql_reference/timeuuid_functions_r.html?hl=now

* Add support for CQL update IF statement.

https://docs.datastax.com/en/cql-oss/3.3/cql/cql_reference/cqlUpdate.html#Conditionallyupdatingcolumns

* Drop table prefixes for CQL SELECTs.

* Switch to single quoting for CQL queries.

https://docs.datastax.com/en/cql-oss/3.3/cql/cql_reference/escape_char_r.html

* Update documentation.

* Use valid CQL in tests.

* Support CQL LIMIT.
2022-09-08 14:39:35 -04:00
Huan Du e6e16111d3 fix #81 refactory struct field parser to make fieldas correct in all cases 2022-09-04 00:09:09 +08:00
Huan Du 6592350faf update docs 2022-07-23 15:11:19 +08:00
Huan Du 72a87cb0b7 refs #78 add new fieldas tag to set AS name for SELECT 2022-07-21 22:14:43 +08:00
Huan DuandGitHub 59acf167e4 update readme to introduce utility methods
Add doc per request in #67
2021-10-21 18:45:08 +08:00
Huan Du 58fddabdd6 update doc 2021-07-25 11:49:14 +08:00
Huan Du 9d74991669 fix #59 support field mapper for Struct 2021-02-21 20:18:09 +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 041d144b16 update travis-ci status icon 2020-12-27 00:07:30 +08:00
Huan Du 51547d1782 fix #51: support new flavor SQLite 2020-12-26 23:51:35 +08:00
Huan Du a650aa79bd add doc for omitempty(tag) 2020-11-02 10:53:27 +08:00
Huan Du ce738c850f fix a typo in README 2020-07-28 12:05:44 +08:00
Huan Du 7239db6838 fix #47. add Union and UnionAll methods 2020-07-28 12:01:33 +08:00
Huan Du 71c2993522 update doc 2019-11-21 14:53:43 +08:00
Huan Du 254d75df2e update doc and test cases again 2019-04-25 18:56:42 +08:00
Huan Du 6a3f9222bd update doc and test cases 2019-04-25 18:47:11 +08:00
Huan Du 477f4420d9 new feature: interpolate args in sql 2019-04-24 17:10:23 +08:00
Huan Du 6044e2f240 refs #18. add CreateTableBuilder 2019-04-22 00:34:10 +08:00
Yann SalaünandGitHub 13caade714 fix typo 2019-03-20 14:44:48 +01:00
Huan Du 015f032529 add a new fieldopt "omitempty" 2019-03-20 00:18:57 +08:00
Huan Du 5e6c0741f7 fix #13. SelectBuilder supports Join and JoinWithOption. 2018-11-23 16:37:46 +08:00
Huan DuandGitHub 57e0443620 Update README.md 2018-04-26 02:40:07 +08:00