71 Commits

Author SHA1 Message Date
Jinzhu
a13b7a6acb Fix OnConflict where order for postgres, close #4073 2021-02-10 14:11:29 +08:00
Jinzhu
435bf70865 Add OnConflict OnConstraint support, close #3882 2021-01-05 21:31:51 +08:00
Philip Sahli
9b8d3b3a0f
fix typo (#3911) 2021-01-04 11:30:05 +08:00
Jinzhu
6c0ee2700a Allow to use Valuer with Eq expression, #3899 2020-12-30 10:42:13 +08:00
vellotis
51b5208599
Fix building of clause.Eq and clause.Neq expressions that fail to handle (*T)(nil) use cases correctly (#3848)
* Update tests to cover building `clause.Eq` and `clause.Neq` when value could be a nil pointer of a primitive

* Fix use cases for `clause.Eq` and `clause.Neq` when value is nil pointer of a primitive type
2020-12-11 14:07:23 +08:00
Jinzhu
694e42d6a1 Fix clause.IN with only one value of multiple rows 2020-11-17 19:11:24 +08:00
Jinzhu
62be27d3ca Add OnConflict UpdateAll support 2020-11-16 20:22:08 +08:00
LeoZhan
832abda7a4
refactor: simplify the writing instead of using struct literal (#3728) 2020-11-08 09:41:43 +08:00
Jinzhu
c915471169 Support Expression for OrderBy clause 2020-11-03 10:30:05 +08:00
Jinzhu
9b2181199d Fix soft delete with OrCondition, close #3627 2020-10-19 14:50:11 +08:00
Jinzhu
08ecef8e0b Fix NamedArguments with nested struct, close #3596 2020-10-13 15:32:29 +08:00
Jinzhu
c9165fe3ca Don't panic when using unmatched vars in query, close #3488 2020-09-18 21:42:27 +08:00
Jinzhu
d002c70cf6 Support named argument for struct 2020-09-17 21:52:41 +08:00
Jinzhu
e583dfa196 Allow negative number for limit 2020-09-11 11:54:21 +08:00
Jinzhu
2242ac6c0e Fix tests & refactor for PR #3429 2020-09-09 10:31:48 +08:00
caelansar
aceb3dad3b correct generated sql 2020-09-08 21:28:04 +08:00
Jinzhu
680dda2c15 Fix combine conditions when using string conditions, close #3358 2020-09-02 20:09:51 +08:00
Jinzhu
496db1f13e Fix named argument with multiple line SQL, fix #3336 2020-08-31 15:45:56 +08:00
Jinzhu
362779575c Fix Select with specific symbol, close #3157 2020-07-17 11:24:24 +08:00
Jinzhu
4456df7a5d Lint with golangci-lint 2020-07-16 11:27:12 +08:00
Jinzhu
72a64bef11 Don't merge clause From 2020-07-15 10:25:10 +08:00
Jinzhu
bba569af2b Add NamedArg support 2020-07-10 12:28:24 +08:00
Jinzhu
9a4941ba70 Test Order/GroupBy 2020-07-06 09:47:14 +08:00
Jinzhu
1a2fabb34d Test Not 2020-07-05 11:56:12 +08:00
SmallTianTian
3c03b6e527
fix no limit no offset. (#3101)
* fix no limit no offset.

* add test for playground.
2020-07-02 18:14:33 +08:00
Jinzhu
a1e35bdc94 Support merge batch data some having primary values 2020-06-20 16:52:15 +08:00
Jinzhu
3d8f6f9cf9 Test GroupConditions 2020-06-20 01:55:30 +08:00
Jinzhu
56bdded0f8 Fix statement modifier support 2020-06-14 12:18:46 +08:00
Jinzhu
649d02fddd Add batch upsert tests 2020-06-09 09:04:32 +08:00
Jinzhu
aaf0725771 Refactor for performance 2020-06-08 17:21:26 +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
82d55b1054 Add OnConflict DoUpdates test 2020-06-07 12:50:00 +08:00
Jinzhu
6937d713c3 Refactor clauses 2020-06-06 22:52:08 +08:00
Jinzhu
38d1cd2bf1 Replace For with Locking 2020-06-06 21:35:28 +08:00
Jinzhu
52b763aab3 Add convert map Assignments helper 2020-06-06 17:47:30 +08:00
Jinzhu
eda2f023b0 Add Distinct support 2020-06-05 19:19:12 +08:00
Jinzhu
8bb05a5a69 Refactor tests files 2020-06-02 10:50:38 +08:00
Jinzhu
e986371a42 Rename package name 2020-06-02 09:18:01 +08:00
Jinzhu
7b6b9c4d22 Add tests for Columns 2020-05-31 00:42:52 +08:00
Jinzhu
c291c2f42c Add Scanner, Valuer tests 2020-05-30 21:05:27 +08:00
Jinzhu
c422d75f4b Add Scopes tests 2020-05-30 19:43:29 +08:00
Jinzhu
d05128be78 OnConflict support for mysql 2020-05-29 22:34:35 +08:00
Jinzhu
ac8708b500 Add FirstOrInit support 2020-05-28 13:12:56 +08:00
Jinzhu
cc064f26ee Add on conflict support 2020-05-25 23:11:42 +08:00
Jinzhu
68a7a8207a Test HasOne Association 2020-05-24 23:07:42 +08:00
Jinzhu
cbc4a81140 Add Count tests 2020-05-24 11:35:19 +08:00
Jinzhu
50aa9be4f1 Add joins support 2020-04-15 09:45:43 +08:00
Jinzhu
af080e6773 Fix primary key tag 2020-03-12 08:39:42 +08:00
Jinzhu
504f42760a Refactor clause Writer 2020-03-09 17:07:00 +08:00