Huan Du and GitHub
88a656d237
Merge pull request #216 from zhangyongding/union-support-limit
...
fix: union limit
2025-09-17 13:48:52 +08:00
zhangyongding
fb0b217e0f
fix: union limit
2025-09-17 10:24:20 +08:00
Huan Du
e47fcc5fb9
fix #213 support typed nil in interpolation
2025-08-11 18:32:23 +08:00
Huan Du and GitHub
6587b1a288
Merge pull request #212 from huandu/feature/returning-clause-issue-210
...
feat: implement Returning method for UpdateBuilder and DeleteBuilder
2025-07-25 11:07:39 +08:00
Huan Du
8e5ccbbee2
feat: implement Returning method for UpdateBuilder and DeleteBuilder
...
Fixes #210
This commit adds the Returning method to both UpdateBuilder and DeleteBuilder,
following the same implementation pattern as InsertBuilder.
Changes:
- Add returning field to UpdateBuilder and DeleteBuilder structs
- Add updateMarkerAfterReturning and deleteMarkerAfterReturning markers
- Implement Returning methods for both builders
- Add RETURNING clause support for PostgreSQL and SQLite flavors
- Add comprehensive test coverage including:
- Basic functionality tests
- Flavor-specific behavior tests
- Edge cases (empty, single, multiple columns)
- Complex scenarios (ORDER BY, LIMIT, CTE)
- SQL injection compatibility
- Method chaining validation
The RETURNING clause is properly positioned after LIMIT and is ignored
for database flavors that don't support it (MySQL, SQL Server, CQL,
ClickHouse, Presto).
Example usage:
ub := Update("users").Set("name = ?", "John").Where("id = ?", 1).Returning("id", "updated_at")
db := DeleteFrom("users").Where("status = ?", "inactive").Returning("id", "deleted_at")
2025-07-24 16:01:37 +00:00
Huan Du and GitHub
b1fd2b84b5
Merge pull request #204 from edznux-dd/nil-pointer-deref
...
[bugfix] Nil pointer deref
2025-07-06 18:55:09 +08:00
Huan Du and GitHub
600a50b33f
Merge pull request #207 from edznux-dd/add-fuzzer
...
Add a fuzz harness for Select
2025-07-06 18:54:44 +08:00
Edouard Schweisguth
6f2ca59f11
Add nil check before executing functions
2025-06-25 11:36:08 +02:00
Edouard Schweisguth
542af0bd67
Add nil check regression for BuildWithFlavor
2025-06-25 11:35:45 +02:00
Edouard Schweisguth
a0cb9722f3
Add regression test
2025-06-25 11:27:06 +02:00
Edouard Schweisguth
19f7503839
Add a fuzz harness for Select
2025-06-25 11:24:11 +02:00
Huan Du
e9d31b7960
fix #200 : PostgreSQL InsertIgnoreInto with subquery doesn't append ON CONFLICT DO NOTHING
2025-06-13 01:05:33 +08:00
Huan Du
d882448972
fix #202 : NotIn with empty values builds "0 = 0"
2025-06-13 00:58:47 +08:00
Huan Du
8ed4b5374f
fix #192 Add new flavor Doris
2025-03-20 19:05:19 +08:00
Huan Du and GitHub
5afad98d5c
Merge pull request #196 from barweiss/fix-presto-limit-and-offset-order
...
Fix #195 the order of LIMIT and OFFSET clauses when using the Presto flavor
2025-03-20 18:28:01 +08:00
Bar Weiss
0f5ba50c2c
Add some in-code documentation
2025-03-20 10:47:05 +02:00
Bar Weiss
feef77c099
Fix the order of LIMIT and OFFSET clauses when using the Presto flavor (issue #195 )
...
Queries that have both a limit and an offset build a query with a limit clause *before* the offset clause.
```go
fmt.Println(Select("*").From("table").Offset(5).Limit(10))
// SELECT * FROM table LIMIT 10 OFFSET 5
```
This seems to generate syntax errors in Trino. [Presto documentation specifies OFFSET before LIMIT](https://prestodb.io/docs/current/sql/select.html#limit-clause ) in the SELECT statement documentation too, but is not very explicit about the reverse not being supported.
If the OFFSET and LIMIT clauses are swapped, the query succeeds.
Expected:
```go
fmt.Println(Select("*").From("table").Offset(5).Limit(10))
// SELECT * FROM table OFFSET 5 LIMIT 10
```
2025-03-20 10:32:26 +02:00
Huan Du and GitHub
903c2500cd
Merge pull request #191 from huandu/feature/returning-id
...
fix #83 : Support RETURNING in InsertBuilder
2025-02-11 15:48:12 +08:00
Huan Du
ffacf24738
fix #83 : Support RETURNING in InsertBuilder
2025-02-11 15:46:25 +08:00
Huan Du and GitHub
3c20969dde
Merge pull request #189 from huandu/feature/limit-offset-using-args
...
Fix #186 : use args in LIMIT and/or OFFSET expression
2025-02-11 15:11:22 +08:00
Huan Du and GitHub
23890851a4
Merge pull request #190 from huandu/feature/prevent-syntax-error-with-zero-values
...
Ignore empty values and expressions to prevent syntax error
2025-02-11 15:10:42 +08:00
Huan Du
61ff9070f0
generate FALSE if values is empty in IN/ALL/SOME/ANY
2025-02-11 15:09:46 +08:00
Huan Du
ee087fd12b
ignore empty values and expressions to prevent syntax error
2025-01-26 15:35:02 +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
bbd370c39c
fix #184 : fix SQL syntax error in WITH ... UPDATE ... FROM
2024-12-05 13:00:55 +08:00
Huan Du and GitHub
0915e09d81
Merge pull request #183 from huandu/feature/select-lateral-derived-table
...
Support LATERAL keyword
2024-12-03 16:02:23 +08:00
Huan Du
e0939dbf05
fix #181 : Support LATERAL keyword
2024-12-01 03:25:59 +08:00
Huan Du and GitHub
e42f1a65bb
Merge pull request #180 from huandu/bug/cond-misuse
...
Avoid stack overflow when Cond is misused
2024-11-06 12:30:42 +08:00
Huan Du and GitHub
495a64ffb9
Merge pull request #179 from huandu/feature/cte-table-for-update-delete
...
Automatically ref names of CTETables in DELETE and UPDATE statements
2024-11-06 12:30:28 +08:00
Huan Du
d8cdbb7ceb
fix #178 : avoid stackoverflow when Cond is misused
2024-11-05 14:24:10 +08:00
Huan Du
e3eef72bb4
refs #176 : Automatically ref names of CTETables in DELETE and UPDATE statement
2024-11-02 23:03:02 +08:00
Huan Du and GitHub
0fa8701293
Merge pull request #177 from rodionovv/flavor_getter
...
Flavor getters
2024-11-01 14:06:10 +08:00
Vasily Rodionov
98718aad2d
new: Added Flavor method to Builder interface
2024-10-31 15:23:25 +05:00
Vasily Rodionov
b28a583417
new: flavor getters
2024-10-30 20:39:31 +05:00
Huan Du and GitHub
75cca5d6cb
Merge pull request #175 from rodionovv/string-validation
...
Ignore empty content to prevent the output of incorrect SQL
2024-10-28 13:52:43 +08:00
Vasily Rodionov
d21fa10b30
test: Added test cases for empty strings in where clause
2024-10-27 22:20:40 +05:00
Vasily Rodionov
9bf5964c7c
fix #172 : added checks for empty strings in conds.
2024-10-27 18:39:54 +05:00
Huan Du
4e13f47b93
fix #171 : no need to escape field any more
2024-10-10 13:20:45 +08:00
Huan Du
619ac5820e
reduce count of memory allocations in Cond.And/Or/Not
2024-09-24 14:40:15 +08:00
Huan Du
e979adcd4a
update doc for IsDistinctFrom and IsNotDistinctFrom
2024-09-23 22:06:35 +08:00
Huan Du
8329700531
fix #169 : support IS [NOT] DISTINCT FROM operator
2024-09-23 22:03:08 +08:00
Huan Du
19835c7b14
update docs in README and godoc
2024-09-10 17:22:08 +08:00
Huan Du and GitHub
57e597eb7d
Merge pull request #168 from vallahaye/167-add-logical-not-and-not-ilike-comparison-operators
...
Add logical NOT and NOT ILIKE operators
2024-09-10 15:49:16 +08:00
Valentin Lahaye
9d726b4cf4
feat(cond): add logical NOT and NOT ILIKE operators
...
Add Cond.Not and Cond.NotILike to build NOT and NOT ILIKE expressions.
Closes #167
2024-09-10 09:39:27 +02:00
Huan Du
03e80e6f8c
refs #164 : new API SelectMore to add more cols to SELECT after calling Select()
2024-09-09 02:05:14 +08:00
Huan Du
cd1b266513
fix #163 : CTE API refactory; see issue for details
2024-09-09 01:52:01 +08:00
Huan Du and GitHub
a6a0e828d9
Merge pull request #162 from arikkfir/add-recursive-cte-support
...
Fix #161 : Add support for recursive CTEs
2024-08-26 11:49:00 +08:00
Arik Kfir
cacc5a5636
feature #161 : add support for recursive CTEs
...
This change adds support for recursive CTEs by introducing the
`WithRecursive` method, which builds a `WITH RECURSIVE` clause.
2024-08-21 17:14:38 +03:00
Huan Du
e8528206c0
fix : #160 SelectBuilder.With appends table names to FROM
2024-08-04 20:29:26 +08:00
Huan Du and GitHub
b6974302a0
Merge pull request #159 from abanoub-fathy/add-ILIKE-helper-method
...
Add ilike helper method
2024-07-26 12:22:41 +08:00