132 Commits

Author SHA1 Message Date
robhafner
e8f48b5c15
fix: limit=0 results (#5735) (#5736) 2022-10-07 20:14:14 +08:00
Bruce MacKenzie
f29afdd329
Rewrite of finisher_api Godocs (#5618) 2022-09-09 11:16:41 +08:00
Bruce MacKenzie
a35883590b
update Delete Godoc to describe soft delete behaviour (#5554) 2022-08-11 11:38:04 +08:00
Jinzhu
75720099b5 Create a new db in FindInBatches 2022-07-18 18:07:05 +08:00
Jinzhu
9fd73ae4f1 Revert "use callback to handle transaction"
This reverts commit 93f28bc116526ba4decdd969a7b2b0b245ad70f1.
2022-07-07 15:06:48 +08:00
Joe
93f28bc116 use callback to handle transaction
- make transaction have before and after hooks, so plugin can have hack before
or after transaction
2022-06-24 10:33:39 +08:00
t-inagaki@hum_op
dc1ae394f3
fixed FirstOrCreate not handled error when table is not exists (#5367)
* fixed FirstOrCreate not handled error when table is not exists

* delete useless part
2022-05-28 22:18:43 +08:00
Cr
7496c3a56e
fix: trx in hooks clone stmt (#5338)
* fix: trx in hooks

* chore: format by gofumpt
2022-05-17 14:13:41 +08:00
Jinzhu
6a6dfdae72 Refactor FirstOrCreate, FirstOrInit 2022-04-26 17:16:48 +08:00
Cr
b49ae84780
fix: FindInBatches with offset limit (#5255)
* fix: FindInBatches with offset limit

* fix: break first

* fix: FindInBatches Limit zero
2022-04-17 09:58:33 +08:00
Jinzhu
d421c67ef5 Remove ErrRecordNotFound error from log when using Save 2022-04-14 10:51:39 +08:00
Cr
a65912c588
fix: FirstOrCreate RowsAffected (#5250) 2022-04-13 15:52:07 +08:00
Jinzhu
0729261b62 Support double ptr for Save 2022-04-08 14:23:25 +08:00
ZhangShenao
f7b52bb649
unify db receiver name (#5215)
Co-authored-by: Shenao Zhang <shenao.zhang@shopee.com>
2022-04-01 08:35:16 +08:00
Jinzhu
6befa0c947 Refactor preload error check 2022-03-17 11:22:25 +08:00
Jinzhu
4e523499d1 Refactor Tx interface 2022-03-01 16:59:50 +08:00
lianghuan
996b96e812 Add TxConnPoolBeginner and Tx interface 2022-03-01 16:59:50 +08:00
Gilad Weiss
f3547e00cc
Inherit clone flag (NewDB) on transaction creation (#5012)
* Inherit clone flag (NewDB) on transaction creation

I find it very reassuring to know that after a finisher API, I get a clean db object for my next queries.
If you look at the example in https://gorm.io/docs i’d see many queries running one after the other.. but in reality they wouldn’t work as the they are portrayed and that’s because in default mode NewDB is false and will make all the clauses stay even after a finisher API.

My solution is just to have the value of the clone flag in the “parent” db object, be injected to its children transactions.

* Fix typo
2022-02-20 08:33:12 +08:00
Jinzhu
39d84cba5f Add serializer support (#5078)
* Update context

* Update GormFieldValuer

* Add Serializer

* Add Serializer Interface

* Refactor gorm field

* Refactor setter, valuer

* Add sync.Pool

* Fix test

* Add pool manager

* Fix pool manager

* Add poolInitializer

* Add Serializer Scan support

* Add Serializer Value method

* Add serializer test

* Finish Serializer

* Fix JSONSerializer for postgres

* Fix JSONSerializer for sqlserver

* Test serializer tag

* Add unixtime serializer

* Update go.mod
2022-02-19 17:02:53 +08:00
Saurabh Thakre
581a879bf1
Added comments to existing methods
Added two comments to describe FirstOrInit and FirstOrCreate methods.
2022-01-31 17:26:28 +05:30
Ning
8c3673286d
preoload not allowd before count (#5023)
Co-authored-by: ningfei <accelerator314@outlook.com>
2022-01-30 18:17:06 +08:00
Jinzhu
eae73624ad Fix return failed to begin transaction error when failed to start a transaction 2022-01-07 10:04:35 +08:00
kinggo
0df42e9afc
feat: add Connection to execute multiple commands in a single connection; (#4982) 2022-01-07 09:49:56 +08:00
Jinzhu
300a23fc31 Check rows.Close error, close #4891 2021-12-02 10:39:24 +08:00
kinggo
d8a710cba2
fix: count() when use group by and only find one record (#4885)
Co-authored-by: 李龙 <lilong.21@bytedance.com>
2021-11-29 20:14:23 +08:00
Jinzhu
270e38c518 Fix duplicated error when Scan, close #4525 2021-11-29 14:23:10 +08:00
Jinzhu
b23c3b290e Don't query with primary key when using Save 2021-11-08 18:49:59 +08:00
kinggo
c170af11e9
fix connections leak (#4826)
* fix connections leak

* fix connections leak

* fix connections leak

* fix connections leak

Co-authored-by: 李龙 <lilong.21@bytedance.com>
2021-11-03 13:39:52 +08:00
Jinzhu
af3fbdc2fc Improve returning support 2021-10-26 22:40:14 +08:00
kinggo
6864a24150
fix:remove the tableName judgment in pluck (#4731) 2021-09-27 22:11:29 +08:00
Jinzhu
12bbde89e6 Fix Scan with interface 2021-09-17 14:04:19 +08:00
Jinzhu
61b018cb94 Fix count with selected * 2021-09-16 11:17:54 +08:00
River
1bb0d8732d
feat: count accpet db.table (#4626)
* feat: count accpet `db`.`table`

* fix: logic fix
2021-08-20 17:37:21 +08:00
Jinzhu
83530ec659 Fix delete order by clause when counting, close #4478 2021-07-13 21:17:43 +08:00
wuwenchi
8bd8d38fe9 Fix Pluck's usage #4473 2021-06-26 21:23:16 +08:00
Jinzhu
8e67a08774 Fix Scopes with Row, close #4465 2021-06-18 15:38:20 +08:00
Tony
a0bddccfe1
Use count(*) instead of count(1) include NULL and non-NULL rows(SQL-92). (#4453) 2021-06-11 21:51:18 +08:00
heige
50e85e14d4
Code optimize (#4415)
* optimize gormSourceDir replace

* fmt.Errorf adjust and Optimize for-break

* strings trim

* feat: avoid using the same name field and if..else optimization adjustment

* optimization callbacks/create.go Create func if...else logic

* fix: callbacks/create.go Create func

* fix FileWithLineNum func and add gormSourceDir unit test

* remove debug print and utils_filenum_test.go
2021-06-10 10:21:28 +08:00
liamrfell
00b252559f
Fix: FirstOrCreate slice out of bounds error when using 'Assigns' (#4436)
Co-authored-by: Liam Fell <liam@lot.to>
2021-06-07 10:39:24 +08:00
Jinzhu
92c3ba9dcc Fix create new db sessions in scopes 2021-05-17 15:36:07 +08:00
Genta Kamitani
26dd4c980a
Fix: FindInBatches ignores errors (#4203) 2021-03-22 14:11:07 +08:00
heige
221d0a0ec1
optimize value of reflection length (#4152) 2021-03-08 10:20:04 +08:00
Jinzhu
189547f615 Fix new session with Begin, close #4120 2021-02-26 16:43:43 +08:00
Jinzhu
9790103e68 Fix Where with empty struct, close #3966 2021-01-19 16:37:49 +08:00
Jinzhu
3d87575e7e make Count compatible with Select with Count func, close #3962 2021-01-18 19:43:04 +08:00
Jinzhu
4a15540504 SkipDefaultTransaction skip CreateInBatches transaction 2021-01-18 11:43:42 +08:00
Jinzhu
79628be2c2 Fix wrong RowsAffected if not data found 2021-01-14 16:01:23 +08:00
Jinzhu
d888c799d7 Change UpdatedAt to current time when doing OnConflict UpdateAll 2021-01-08 19:20:42 +08:00
Jinzhu
5e72cd9a2b Add ErrPrimaryKeyRequired if schema has no primary key defined 2021-01-06 14:42:42 +08:00
Jinzhu
468152d45b Add DisableNestedTransaction support 2020-12-16 19:33:35 +08:00