Skip to content

Releases: huandu/go-sqlbuilder

v1.38.0

10 Oct 08:31

Choose a tag to compare

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 OrderByAsc and OrderByDesc to SelectBuilder/UpdateBuilder/DeleteBuilder/UnionBuilder for better readability. The old methods OrderBy/Asc/Desc are marked as deprecated. #214

New Contributors

Full Changelog: v1.37.0...v1.38.0

v1.37.0

17 Sep 11:54
044cf35

Choose a tag to compare

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

25 Jul 04:06
51f40ba

Choose a tag to compare

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 UpdateBuilder and DeleteBuilder in #212

New Contributors

Full Changelog: v1.35.0...v1.36.0

v1.35.0

20 Mar 11:10

Choose a tag to compare

What's Changed

  • NEW: New flavor Doris, which is a dialect of MySQL. See discussion in #192 for details.
  • FIX: the order of LIMIT and OFFSET clauses when using the Presto flavor #195 in #196

New Contributors

Full Changelog: v1.34.0...v1.35.0

v1.34.0

11 Feb 08:09
87b9c12

Choose a tag to compare

What's Changed

  • #189: Use args in LIMIT and/or OFFSET expression to optimize query plan caching.
  • #190: Ignore empty values and expressions to prevent syntax error.
  • #191: Support RETURNING in InsertBuilder.
    • See discussion in #83 for details.

Full Changelog: v1.33.0...v1.34.0

v1.33.0: Support `LATERAL` keyword

03 Dec 08:12
c4b67f5

Choose a tag to compare

What's Changed

  • Support LATERAL keyword #181 #183 (Thanks @therve for your ideas)
    • Add a new method LateralAs in SelectBuilder to build LATERAL JOIN expression. Read sample code for LateralAs on GoDoc for details.

Full Changelog: v1.32.0...v1.33.0

v1.32.0: Enhancements and Bug Fixes in SQL Statement Handling and Error Identification

06 Nov 04:59
5067ee7

Choose a tag to compare

What's Changed

  • NEW: Flavor getters by @rodionovv in #177
    • There is a new method Flavor() in Builder to get current flavor set in a builder.
  • NEW: Automatically reference names of CTETables in DELETE and UPDATE statements. #179
    • Based on the discussion in issue #176, the capability previously used with CTETable to automatically include the CTE table name in the FROM clause of SELECT statements has now been extended to UPDATE and DELETE statements.
  • FIX: Avoid stack overflow when Cond is misused. #180
    • Based on the discussion in issue #178, users may call this method to create Cond for 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 */, where n is the sequence number of the problematic variable, allowing users to quickly pinpoint the issue.

Full Changelog: v1.31.0...v1.32.0

New feature: Ignore empty content to prevent the output of incorrect SQL

28 Oct 06:13
be6fb8b

Choose a tag to compare

What's Changed

  • Cond and WhereClause will actively ignore empty content to prevent the output of syntactically incorrect SQL #175 by @rodionovv
    • In previous version, Cond and WhereClause can produce syntax errors when any of required parameters field, op or expr is 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
      • sb := Select("*").From("t"); sb.Where(sb.Equal("", 0))
        • Now: SELECT * FROM t
        • Previous version: SELECT * FROM t WHERE = ?

New Contributors

Full Changelog: v1.30.0...v1.31.0

New feature: Add "IS [NOT] DISTINCT FROM" comparison operators to `Cond`

24 Sep 07:18

Choose a tag to compare

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,Cond can 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 is PostgreSQL, it builds "field IS DISTINCT FROM $1". For MySQL, which does not support this operator, it builds the functionally equivalent expression "NOT field <=> ?".

Full Changelog: v1.29.1...v1.30.0

New feature: Common Table Expression enhancement

08 Sep 18:55

Choose a tag to compare

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 RECURSIVE clause;
  • Enabled the use of CTE tables in JOIN and WHERE clauses, excluding FROM;
  • Incorporated WITH support in UPDATE and DELETE statements.

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.

  • CTEQuery vs CTETable:
    • In prior versions, a quirk in the design automatically appended all table names defined in CTEBuilder to the FROM clause of a SELECT statement, which hindered the exclusive use of CTE tables in JOIN or WHERE clauses.
    • Based on the conversation in issue #163, we proposed two solutions and selected the most viable. To summarize, the new API CTEQuery constructs CTE queries without any unintended consequences; meanwhile, CTETable retains its original functionality, effectively turning the previous side effect into a deliberate feature.
  • Introduction of CTEQueryBuilder:
    • CTEQueryBuilder is now the sole builder for crafting CTE query expressions, replacing the previous approach.
    • CTETableBuilder has been repurposed as a type alias for CTEQueryBuilder and 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 SelectMore in SelectBuilder allows for the addition of further columns to a SELECT statement post the Select() method call.

New Contributors

Full Changelog: v1.28.0...v1.29.0