Releases: huandu/go-sqlbuilder
Releases · huandu/go-sqlbuilder
v1.38.0
What's Changed
- [NEW] Implement returning method on SQL Server by @Bugadinho in #220
- [FIX] Add document to demonstrate how to write nested
JOIN. #217 - [NEW] Add
OrderByAscandOrderByDesctoSelectBuilder/UpdateBuilder/DeleteBuilder/UnionBuilderfor better readability. The old methodsOrderBy/Asc/Descare marked as deprecated. #214
New Contributors
- @Bugadinho made their first contribution in #220
Full Changelog: v1.37.0...v1.38.0
v1.37.0
What's Changed
- [NEW] Support clone (deep copy) in all builders (#218)
- [BUG] Fix union limit syntax error with some flavor (#216) Thanks, @zhangyongding
- [BUG] Support typed nil in interpolation (#213)
Full Changelog: v1.36.0...v1.37.0
v1.36.0
What's Changed
- Add a fuzz harness for Select by @edznux-dd in #207
- [bugfix] Nil pointer deref by @edznux-dd in #204
- feat: implement Returning method for
UpdateBuilderandDeleteBuilderin #212
New Contributors
- @edznux-dd made their first contribution in #207
Full Changelog: v1.35.0...v1.36.0
v1.35.0
What's Changed
- NEW: New flavor
Doris, which is a dialect ofMySQL. See discussion in #192 for details. - FIX: the order of LIMIT and OFFSET clauses when using the Presto flavor #195 in #196
- Thanks for your contribution, @barweiss.
New Contributors
Full Changelog: v1.34.0...v1.35.0
v1.34.0
What's Changed
- #189: Use
argsinLIMITand/orOFFSETexpression to optimize query plan caching.- Thanks @stavros-k for raising this issue in #186.
- #190: Ignore empty values and expressions to prevent syntax error.
- Thanks @ErikBooijMB for raising this issue in #188.
- #191: Support
RETURNINGinInsertBuilder.- See discussion in #83 for details.
Full Changelog: v1.33.0...v1.34.0
v1.33.0: Support `LATERAL` keyword
What's Changed
- Support
LATERALkeyword #181 #183 (Thanks @therve for your ideas)- Add a new method
LateralAsinSelectBuilderto build LATERAL JOIN expression. Read sample code forLateralAson GoDoc for details.
- Add a new method
Full Changelog: v1.32.0...v1.33.0
v1.32.0: Enhancements and Bug Fixes in SQL Statement Handling and Error Identification
What's Changed
- NEW:
Flavorgetters by @rodionovv in #177- There is a new method
Flavor()inBuilderto get current flavor set in a builder.
- There is a new method
- NEW: Automatically reference names of
CTETables inDELETEandUPDATEstatements. #179- Based on the discussion in issue #176, the capability previously used with
CTETableto automatically include the CTE table name in theFROMclause ofSELECTstatements has now been extended toUPDATEandDELETEstatements.
- Based on the discussion in issue #176, the capability previously used with
- FIX: Avoid stack overflow when
Condis misused. #180- Based on the discussion in issue #178, users may call this method to create
Condfor building various conditions, which is a misuse, but we cannot completely prevent this error. - To facilitate problem identification for users, in the event of misuse of
NewCond(), the generated SQL will include the pattern/* INVALID ARG $n */, wherenis the sequence number of the problematic variable, allowing users to quickly pinpoint the issue.
- Based on the discussion in issue #178, users may call this method to create
Full Changelog: v1.31.0...v1.32.0
New feature: Ignore empty content to prevent the output of incorrect SQL
What's Changed
CondandWhereClausewill actively ignore empty content to prevent the output of syntactically incorrect SQL #175 by @rodionovv- In previous version,
CondandWhereClausecan produce syntax errors when any of required parametersfield,oporexpris empty. This release fixes this issue by actively ignore these invalid values. - Here are samples affected by this change.
Select("*").From("t").Where("").String()- Now:
SELECT * FROM t - Previous version:
SELECT * FROM t WHERE
- Now:
sb := Select("*").From("t"); sb.Where(sb.Equal("", 0))- Now:
SELECT * FROM t - Previous version:
SELECT * FROM t WHERE = ?
- Now:
- In previous version,
New Contributors
- @rodionovv made their first contribution in #175
Full Changelog: v1.30.0...v1.31.0
New feature: Add "IS [NOT] DISTINCT FROM" comparison operators to `Cond`
What's New
- Add "IS [NOT] DISTINCT FROM" comparison operators to
Cond#169 - Automatically build compatible operators for a flavor.
- If a database system does not support an operator,
Condcan automatically build compatible syntax as a substitute. - For example, calling
IsDistinctFrom("field", value)automatically determines which expression to output based on the current database flavor. If the flavor isPostgreSQL, it builds "field IS DISTINCT FROM $1". ForMySQL, which does not support this operator, it builds the functionally equivalent expression "NOT field <=> ?".
- If a database system does not support an operator,
Full Changelog: v1.29.1...v1.30.0
New feature: Common Table Expression enhancement
Following discussions in issue #161, @arikkfir and I have tackled several key gaps in the Common Table Expression (CTE) related APIs:
- Implemented support for the
WITH RECURSIVEclause; - Enabled the use of CTE tables in
JOINandWHEREclauses, excludingFROM; - Incorporated
WITHsupport inUPDATEandDELETEstatements.
To introduce these features, we've made substantial API updates designed to be backward compatible, ensuring no disruption to existing implementations. However, all users of the CTE APIs should be cognizant of these enhancements.
CTEQueryvsCTETable:- In prior versions, a quirk in the design automatically appended all table names defined in
CTEBuilderto theFROMclause of aSELECTstatement, which hindered the exclusive use of CTE tables inJOINorWHEREclauses. - Based on the conversation in issue #163, we proposed two solutions and selected the most viable. To summarize, the new API
CTEQueryconstructs CTE queries without any unintended consequences; meanwhile,CTETableretains its original functionality, effectively turning the previous side effect into a deliberate feature.
- In prior versions, a quirk in the design automatically appended all table names defined in
- Introduction of
CTEQueryBuilder:CTEQueryBuilderis now the sole builder for crafting CTE query expressions, replacing the previous approach.CTETableBuilderhas been repurposed as a type alias forCTEQueryBuilderand is deprecated. It is advised that this alias may be phased out in upcoming releases.
What's New
- Recursive CTE support added by @arikkfir in #162
- Overhaul of the CTE API by @huandu in issue #163
- A new method
SelectMoreinSelectBuilderallows for the addition of further columns to aSELECTstatement post theSelect()method call.
New Contributors
Full Changelog: v1.28.0...v1.29.0