Commit Graph

1613 Commits

Author SHA1 Message Date
Emir Beganovic 59594877da Fix unsafe concurrent SingularTable method call 2019-04-14 12:30:11 +04:00
Emir Beganović 9df293e681
Merge pull request #2324 from xwjdsh/bugfix/having-on-count
fix the case that using Having on Count
2019-04-14 11:40:45 +04:00
Emir Beganović 3e240d1fef
Merge branch 'master' into bugfix/having-on-count 2019-04-14 10:50:05 +04:00
Emir Beganović 2b88a805cf
Merge pull request #2385 from emirb/feature/cleanup-go-mod
Cleanup go.mod
2019-04-14 10:48:51 +04:00
Emir Beganovic da037b0454 Cleanup go.mod 2019-04-14 10:43:59 +04:00
Momo733 1c62bf1e57
fix save err when specify a table name
s.New() will clear all search conditions and search value,when I use Table() to set a table name. Then FirstOrCreate() will use struct name as my database table name,so It doesn't work.
2019-04-13 14:23:35 +08:00
Emir Beganović efcabc8be3
Merge pull request #2330 from xwjdsh/bugfix/return-empty-slice-many2many
Return empty slice for many2many if no asscociation was found
2019-04-11 09:31:25 +02:00
Emir Beganović 814535d96c
Merge branch 'master' into bugfix/having-on-count 2019-04-11 09:29:59 +02:00
Emir Beganović 3819d1d218
Merge branch 'master' into bugfix/return-empty-slice-many2many 2019-04-11 09:25:55 +02:00
Emir Beganović fdd41cf0b0
Merge pull request #2331 from xwjdsh/bugfix/fix-many2many-table-name
fix the table name of many2many
2019-04-11 08:14:42 +02:00
Emir Beganović cecf452d44
Merge branch 'master' into bugfix/fix-many2many-table-name 2019-04-11 08:04:39 +02:00
Jony4 071b657418 fix TagSettings' map has "":"" value (#2372) 2019-04-05 08:00:48 +08:00
JUN JIE NAN bc5d3f07a8 Removed the deps on uuid and appengine (#2354)
gofrs/uuid was used in testing only, and go module count testing
depends in. This patch removed the gofrs/uuid depends, and appengine
as well.
2019-04-05 07:59:02 +08:00
Wendell Sun 14e0507fd2 fix the table name of many2many 2019-03-14 12:35:57 +08:00
Wendell Sun 2fb2c0d3b2 return empty slice for many2many if no asscociation was found 2019-03-14 02:33:42 +08:00
Wendell Sun 26e8799a19 fix the case that using Having on Count 2019-03-11 21:16:50 +08:00
Ali Koyuncu 8b07437717 add mysql insert modifiers (#2269) 2019-03-10 20:17:21 +08:00
kuangzhiqiang d239c4cab8 error log show trace file (#2296) 2019-03-10 20:03:55 +08:00
haoc7 c721a198a7 create table add column comment (#2298) 2019-03-10 20:01:57 +08:00
Jinzhu d7ef7871a4 Fix tests 2019-03-10 19:33:49 +08:00
Jinzhu f3a0fc1566 Fix go.mod 2019-03-10 19:33:23 +08:00
Satoshi Inoue 4b13e079fc go modules (#2279) 2019-03-10 07:29:21 +08:00
Jinzhu 906799fef2 Better log output for uint* 2019-02-10 15:39:40 +08:00
aixiaoxiang 8494ecdc98 Better log output int8, int, int16, int32, int64, float32, float64, bool. (#2258)
* Better log output int, int16, int32, int64, int8, float32, float64.

* Better log output bool
2019-02-10 15:37:39 +08:00
蜻蜓特派员 9f1a7f5351 optimize getColumnAsArray (#2196) 2019-01-02 21:32:08 +08:00
Brent Hughes 8316f94b72 Fix Panic in test scenerio (#2131)
I have found that there are times when testing that if I did not create the database through Open() it will not have the parent set and cause a panic when it hits this code path.
2019-01-02 21:28:46 +08:00
Edgar Fournival a6382da485 Do not set CreatedAt if blank during Save (#2207) 2019-01-02 21:28:02 +08:00
David Zhang e2cfd6be3b LintFix: Make receiver name of structField consistent (#2164)
* Make receiver name of structField consistent

* Change s to sf
2019-01-02 21:27:17 +08:00
李鹏 ac6c89ec0c search不需要再clone,dbClone内的search已经是一个全新的了 (#2179) 2019-01-02 21:25:37 +08:00
Zed 447d578628 amended comments in error.go for clarity and grammar; for more polish when using IDEs (e.g. VSCODE) that show comments as help text (#2182) 2019-01-02 21:23:43 +08:00
Sai 5ad6f621e6 logMode codes more readable (#2216) 2018-12-13 21:04:51 +08:00
Jun Jie Nan 472c70caa4 Check valuer interface before scan value (#2155)
Scan interface only accept int64, float64, bool, []byte, string,
time.Time or nil. When do scan, it's better to check whether the type
support valuer interface and do convert.
2018-11-03 22:14:39 +08:00
teresy 68f5d25d64 simplify cases of strings.Index with strings.Contains (#2162) 2018-11-03 21:56:27 +08:00
RikiyaFujii 50c61291de add comment (#2163)
* add comment

* typo
2018-11-03 21:55:52 +08:00
Iskander (Alex) Sharipov 742154be9a rewrite if-else chain as switch statement (#2121)
From effective Go: https://golang.org/doc/effective_go.html#switch

> It's therefore possible—and idiomatic—to write an if-else-if-else chain as a switch.
2018-10-07 08:49:37 +08:00
Artemij Shepelev f6260a0085 Second part of the defaultTableName field race fix (#2060)
* fix (https://github.com/jinzhu/gorm/issues/1407)

* changed map with mutex to sync.Map (https://github.com/jinzhu/gorm/issues/1407)

* removed newModelStructsMap func

* commit to rerun pipeline, comment changed

* fix race with defaultTableName field (again)
2018-09-22 19:59:11 +08:00
ch3rub1m 5be9bd3413 Rollback transaction when a panic happens in callback (#2093) 2018-09-14 15:53:49 +08:00
Eyal Posener 123d4f50ef lock TagSettings structure when modified (#1796)
The map is modified in different places in the code which results in race conditions
on execution.
This commit locks the map with read-write lock when it is modified
2018-09-10 07:11:00 +08:00
gstvg 282f11af19 Support only preloading (#1926)
* add support for only preloading relations on an already populated model

* Update callback_query.go

comments
2018-09-10 06:52:32 +08:00
Phillip Shipley 588b598f9f Fix issue updating models with foreign key constraints (#1988)
* fix update callback to not try to write zero values when field has default value

* fix to update callback for gorm tests
2018-09-10 06:50:22 +08:00
Gustavo Brunoro 26fde9110f getValueFromFields doesn't panic on nil pointers (#2021)
* `IsValid()` won't return `false` for nil pointers unless Value
  is wrapped in a `reflect.Indirect`.
2018-09-10 06:47:18 +08:00
maddie 012d147974 Improve preload speed (#2058)
All credits to @vanjapt who came up with this patch.

Closes #1672
2018-09-10 06:45:55 +08:00
Aaron Leung 73e7561e20 Use sync.Map for DB.values (#2064)
* Replace the regular map with a sync.Map to avoid fatal concurrent map reads/writes

* fix the formatting
2018-09-10 06:26:29 +08:00
Ikhtiyor d3e666a1e0 save_associations:true should store related item (#2067)
* save_associations:true should store related item, save_associations priority on related objects

* code quality
2018-09-10 06:25:26 +08:00
kuangzhiqiang 12607e8bdf for go1.11 go mod (#2072)
when used go1.11 gomodules the code dir will be `$GOPATH/pkg/mod/github.com/jinzhu/gorm@*/`
fileWithLineNum check failed
2018-09-10 06:14:05 +08:00
Xy Ziemba 71b7f19aad Fix scanning identical column names occurring >2 times (#2080)
Fix the indexing logic used in selectedColumnsMap to skip fields
that have already been seen. The values of selectedColumns map
must be indexed relative to fields, not relative to selectFields.
2018-09-10 06:12:58 +08:00
Jinzhu dc3b2476c4 Don't save ignored fields into database 2018-09-10 06:03:41 +08:00
Adem Özay 6f58f8a52c added naming strategy option for db, table and column names (#2040) 2018-09-10 05:52:20 +08:00
Eason Lin 32455088f2 doc: document ErrRecordNotFound error more clear (#2015)
* doc: document ErrRecordNotFound error more clear

* fix goimports

* fix goimports

* undo change
2018-08-19 07:14:33 +08:00
hector 53995294ef Change buildCondition TableName to struct's TableName when query is interface{} (#2011) 2018-08-19 07:13:16 +08:00