Releases: huandu/go-sqlbuilder
New feature: Support Common Table Expression and ILIKE
What's Changed
- Implement
CTEBuilder
andCTETableBuilder
to support Common Table Expression (CTE) by @huandu in #157- Samples can be found in the document for
With
andCTEBuilder
.
- Samples can be found in the document for
- Add ILIKE helper in
SelectBuilder
,UpdateBuilder
andDeleteBuilder
by @abanoub-fathy in #159
New Contributors
- @abanoub-fathy made their first contribution in #159
Full Changelog: v1.27.3...v1.28.0
New feature: New builder `WhereClause` dedicated for WHERE clause
Due to the importance of the WHERE
statement in SQL, we often need to continuously append conditions and even share some common WHERE
conditions among different builders. Therefore, we abstract the WHERE
statement into a WhereClause
struct, which can be used to create reusable WHERE
conditions.
I hope the WhereClause
can help more developers to build more and more valuable SQL/DB related packages on top of this package. It's extremely welcome!
What's Changed
- #147 [NEW]
WhereClause
: A new dedicated builder for WHERE. Thanks for raising this idea to me in #145, @LeDuyViet. - #146 Optimize paging syntax for Informix flavor SQL. Thanks, @zhangyongding.
Full Changelog: v1.26.0...v1.27.0
New feature: Support Informix SQL
What's Changed
- #140 Feature: New flavor
Informix
. Thanks for your contribution, @zhangyongding.
Full Changelog: v1.25.0...v1.26.0
New feature: Return number of required clause in builders
Per discussion in #134, add methods to return number of required clause in builders, so that we can know whether a builder can build a valid SQL. Thanks @0x9ef for raising this issue.
Full Changelog: v1.24.0...v1.25.0
New feature: Support `INSERT INTO ... SELECT` statement
What's Changed
- #133 Add sub-select builder for
InsertBuilder
to supportINSERT INTO ... SELECT
statement. Thanks, @cemremengu.
Full Changelog: v1.23.0...v1.24.0
New feature: Support new flavor `Oracle`
What's Changed
- #118, #126: Support new flavor
oracle
. Thanks for your contribution, @zhangyongding. - #125: Add new alias functions in
Cond
for better readability.
Full Changelog: v1.22.0...v1.23.0
New feature: Tuple and enhanced SQL injection
What's Changed
- #108: Support tuple now. See Tuple sample to understand how to use it.
- #115: All builders follow a new rule - don't generate a SQL clause if related values are not set. This feature enables us to write SQL like this
NewSelectBuilder().SQL("SELECT foo FROM bar").Where(/*...*/)
.
Full Changelog: v1.21.0...v1.22.0
New feature: Flavor for Presto and Exists/NotExists/All/Any/Some for conditions
What's Changed
Full Changelog: v1.20.0...v1.21.0
New feature: Filter struct fields using WithTag and WithoutTag
When we build an UPDATE or INSERT SQL with Struct
, we may need to filter out struct fields representing primary key or those should not be updated. Before v1.20.0, we have to define several combinations of fieldtag
tag for every UPDATE or INSERT. It's not convenient.
To address this issue, there is a new method WithoutTag
in Struct
to explicitly exclude fields tagged with tags, so that we can simply tag fields as "pk" and call st.WithoutTag("pk").Update("table")
to filter them out. And WithTag
is upgraded to accept more than one tag. With WithTag
and WithoutTag
, we can build a complex struct field filter for all kinds of requirement.
To learn how to use these method, checkout document and samples in Struct
, Struct.WithTag
and Struct.WithoutTag
.
One more thing. All *ForTag
methods in Struct
are deprecated. It's highly recommended to use st.WithTag("tag").Select("table")
to replace st.SelectForTag("table", "tag")
.
Special thanks to @wangmir for your great thoughts and code review feedback.
Full Changelog: v1.19.0...v1.20.0
New feature: Flavor for CQL
We add a new flavor CQL
in this package. See #85 for details. Thanks for your contribution, @SpencerC.
Full Changelog: v1.18.0...v1.19.0