Commit Graph

85 Commits

Author SHA1 Message Date
Jinzhu af3fbdc2fc Improve returning support 2021-10-26 22:40:14 +08:00
River 851fea0221
fix: QuoteTo not fully support raw mode (#4735)
* fix: QuoteTo not fully support raw mode

* fix: table alias without AS

* test: clause.Column/Table quote test

* fix: revert table alias quote
2021-09-29 14:02:35 +08:00
Jim 5202529ea1
fix (clause/expression): Allow sql stmt terminator (#4693)
Allow the sql stmt terminator ";" at the end of a named parameter.

Example: select * from table_name where name == @name;
2021-09-20 21:40:48 +08:00
Sec Cake 093694fbf2
Fix extra 'AND' when len(values) == 0 ON IN.NegationBuild() (#4618) 2021-08-20 18:06:48 +08:00
River 25f561a742
feat: QuoteTo accept clause.Expr (#4621)
* feat: QuoteTo accept clause.Expr

* test: update Expr build test
2021-08-19 14:33:18 +08:00
River ac97aec513
New Comma Expression (#4524)
* Add new comma expression

* Add comma expression unit test
2021-07-14 15:51:24 +08:00
Jinzhu 76cd73cb82 Fix wipes out MySQL global variables from the query, close #4515 2021-07-13 18:48:43 +08:00
Vitaliy Shein dd8bf88eb9
add Target where clause for on conflict (#4442)
Co-authored-by: Vitaliy Shein <vitaliy.shein@thebricks.com>
2021-06-07 10:39:00 +08:00
Jinzhu 9abac96546 Fix Eq, Neq support slice of data 2021-05-31 17:21:27 +08:00
Jinzhu 14e96080d8 Eq, Neq support slice of data 2021-05-31 15:25:38 +08:00
Karolos Lykos f0d0bbbc10
Added missing white space (#4330)
* Added missing white space

* Added missing white space

* Added missing white space
2021-04-29 07:15:37 +08:00
Jinzhu 33601dc72f Support Having w/o Group 2021-03-30 18:28:09 +08:00
Ratan Phayade a3abb5fedf
support named params in Select API (#4142)
* adds support for named arguments in select

* changes clause identifies and adds test
2021-03-07 10:59:00 +08:00
Jinzhu 90476fea7a Fix Join with slice IN, close #4133 2021-03-04 18:40:47 +08:00
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