18 Commits

Author SHA1 Message Date
Jinzhu
940358e0dd Fix tests doesn't follow https://gorm.io/docs/method_chaining.html convention 2024-01-12 16:42:21 +08:00
Mikhail Faraponov
2990790fbc
Use WriteByte for single byte operations (#5167)
Co-authored-by: Mikhail Faraponov <mikefaraponov@Mikhails-MacBook-Pro.local>
2022-03-17 22:54:30 +08:00
sammyrnycreal
5edc78116f Fixed the use of "or" to be " OR ", to account for words that contain "or" or "and" (e.g., 'score', 'band') in a sql statement as the name of a field. 2022-02-20 08:22:21 +08:00
kinggo
8dde09e0be
fix: generate sql incorrect when use soft_delete and only one OR (#4969)
* fix: generate sql incorrect when use soft_delete and only one OR
2021-12-30 11:47:14 +08:00
Emre Güllü
2c3fc2db28
Fix: Where clauses with named arguments may cause generation of unintended queries (#4937) 2021-12-21 19:50:00 +08:00
Jinzhu
9b2181199d Fix soft delete with OrCondition, close #3627 2020-10-19 14:50:11 +08:00
Jinzhu
680dda2c15 Fix combine conditions when using string conditions, close #3358 2020-09-02 20:09:51 +08:00
Jinzhu
4456df7a5d Lint with golangci-lint 2020-07-16 11:27:12 +08:00
Jinzhu
1a2fabb34d Test Not 2020-07-05 11:56:12 +08:00
Jinzhu
3d8f6f9cf9 Test GroupConditions 2020-06-20 01:55:30 +08:00
Jinzhu
8f8d549ca3 Refactor merge where exprs 2020-06-08 09:13:34 +08:00
Douglas Danger Manley
72d0fa6196 Fix Statement Where clone array corruption in v2
Method-chaining in gorm is predicated on a `Clause`'s `MergeClause`
method ensuring that the two clauses are disconnected in terms of
pointers (at least in the Wherec case).

However, the original Where implementation used `append`, which
only returns a new instance if the backing array needs to be resized.
In some cases, this is true.  Practically, go doubles the size of the
slice once it gets full, so the following slice `append` calls would
result in a new slice:

* 0 -> 1
* 1 -> 2
* 2 -> 4
* 4 -> 8
* and so on.

So, when the number of "where" conditions was 0, 1, 2, or 4, method-chaining
would work as expected.  However, when it was 3, 5, 6, or 7, modifying the
copy would modify the original.

This also updates the "order by", "group by" and "set" clauses.
2020-06-07 16:54:01 -04:00
Jinzhu
6937d713c3 Refactor clauses 2020-06-06 22:52:08 +08:00
Jinzhu
504f42760a Refactor clause Writer 2020-03-09 17:07:00 +08:00
Jinzhu
c1afe19728 Add benchmark tests for clause 2020-02-14 00:09:44 +08:00
Jinzhu
1f38ec4410 Finish clauses tests 2020-02-08 23:23:45 +08:00
Jinzhu
0160bab7dc Add clause tests 2020-02-05 18:28:58 +08:00
Jinzhu
d833efe8b9 Work on clauses 2020-02-02 19:11:17 +08:00