A flexible and powerful SQL string builder library plus a zero-config ORM.
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!
WhereClause
: A new dedicated builder for WHERE. Thanks for raising this idea to me in #145, @LeDuyViet.Full Changelog: https://github.com/huandu/go-sqlbuilder/compare/v1.26.0...v1.27.0
Informix
. Thanks for your contribution, @zhangyongding.Full Changelog: https://github.com/huandu/go-sqlbuilder/compare/v1.25.0...v1.26.0
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: https://github.com/huandu/go-sqlbuilder/compare/v1.24.0...v1.25.0
InsertBuilder
to support INSERT INTO ... SELECT
statement. Thanks, @cemremengu.Full Changelog: https://github.com/huandu/go-sqlbuilder/compare/v1.23.0...v1.24.0
oracle
. Thanks for your contribution, @zhangyongding.Cond
for better readability.Full Changelog: https://github.com/huandu/go-sqlbuilder/compare/v1.22.0...v1.23.0
NewSelectBuilder().SQL("SELECT foo FROM bar").Where(/*...*/)
.Full Changelog: https://github.com/huandu/go-sqlbuilder/compare/v1.21.0...v1.22.0
Cond
.Full Changelog: https://github.com/huandu/go-sqlbuilder/compare/v1.20.0...v1.21.0
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: https://github.com/huandu/go-sqlbuilder/compare/v1.19.0...v1.20.0
We add a new flavor CQL
in this package. See #85 for details. Thanks for your contribution, @SpencerC.
Full Changelog: https://github.com/huandu/go-sqlbuilder/compare/v1.18.0...v1.19.0
We add a new flavor ClickHouse
in this package. See #92 for details. Thanks for your contribution, @hanyuancheung.
Full Changelog: https://github.com/huandu/go-sqlbuilder/compare/v1.17.0...v1.18.0