Commit Graph

1384 Commits

Author SHA1 Message Date
Jinzhu f53af2a236 Don't preload if has any error 2016-01-03 14:21:21 +08:00
Jinzhu 8a0c77e5fc Fix all tests for GetModelStruct 2016-01-03 14:16:58 +08:00
Jinzhu 4bc06a21c1 Refactor GetModelStruct 2016-01-03 14:04:59 +08:00
Jinzhu 6a5a2dbc55 Refactor GetModelStruct 2016-01-03 13:10:17 +08:00
Jinzhu 4e45e6dc2d Use field.TagSettings 2016-01-03 10:00:18 +08:00
Jinzhu 19b85b1f17 Compatible with both gorm, sql tag 2016-01-03 09:52:27 +08:00
Jinzhu 5d2b9bfe34 Refactor GetModelStruct 2016-01-03 09:46:07 +08:00
Jinzhu 9455215e61 Add association tests for composite primary key 2015-12-31 11:17:10 +08:00
Jinzhu 934e97b018 Don't need NOT IN conditions when there are no primary keys found 2015-12-30 15:34:56 +08:00
Jinzhu 9a63fb28ba Update README 2015-12-26 20:46:25 +08:00
Jinzhu 9776eea2a2 Update README 2015-12-26 20:28:40 +08:00
Jinzhu c087e6dcc6 Remove unnecessary saving SQL when Append new association 2015-12-26 19:49:31 +08:00
Jinzhu e8fe7c5e34 Update README for Association Mode 2015-12-26 17:13:41 +08:00
Jinzhu a563efdd27 Update association tests 2015-12-26 16:45:53 +08:00
Jinzhu 4c1f03fee3 Don't set foreign key to be null when delete with a wrong relation 2015-12-26 16:19:38 +08:00
Jinzhu 300b74f15f Refactor association Delete 2015-12-26 16:06:53 +08:00
Jinzhu e65f94b287 Fix association Append for polymorphic 2015-12-26 15:20:40 +08:00
Jinzhu c88960b9b0 Add more tests for TestHasOne 2015-12-26 14:26:21 +08:00
Jinzhu 9ed070d386 Fix tests on CI 2015-12-26 14:00:18 +08:00
Jinzhu c23185af54 Refactor association Delete 2015-12-26 00:23:45 +08:00
Jinzhu f6ea3afc8d Refactor association Replace 2015-12-25 23:30:57 +08:00
Jinzhu f13dcd8bc0 Refactor association Replace 2015-12-25 20:43:51 +08:00
Jinzhu 93b512be47 Refactor association Clear, Replace 2015-12-25 19:35:36 +08:00
Jinzhu 4719ee7b1f Add Replace support for has many associations 2015-12-25 19:08:10 +08:00
Jinzhu a00fb4db04 Add Delete support for has many associations 2015-12-25 18:42:26 +08:00
Jinzhu a00cb7432c Update BelongsTo test 2015-12-25 17:52:09 +08:00
Jinzhu 715d7951aa Test HasOne relations for normal foreign key or scanner 2015-12-25 17:36:47 +08:00
Jinzhu affb64b04b Add BelongsTo support for association Clear 2015-12-25 17:32:28 +08:00
Jinzhu c85f00bcd2 Add BelongsTo support for association Delete 2015-12-25 17:09:37 +08:00
Jinzhu d57867eb46 Make Replace support other associations 2015-12-25 15:49:41 +08:00
Jinzhu 0ce635cc67 Add Append support for other associations 2015-12-25 15:25:37 +08:00
Jinzhu 4677215ef4 Fix get type Name from scope 2015-12-25 12:20:45 +08:00
Jinzhu f8c3ad6af3 Format time first when testing 2015-12-25 11:50:55 +08:00
Jinzhu 4a821a5bef Merge pull request #768 from pwaller/patch-1
Give (*ModelStruct).TableName() a pointer receiver
2015-12-24 08:22:35 +08:00
Peter Waller 5ba59aec5f Give (*ModelStruct).TableName() a pointer receiver
There was a data race caused by the copy of the ModelStruct. See #723.

Fixes #723.
2015-12-23 10:42:03 +00:00
Jinzhu d209be3138 Merge pull request #767 from levinalex/patch-1
clean up wording in README
2015-12-18 20:17:59 +08:00
Levin Alexander 2f85c0e4d6 clean up wording in README
made the paragraph about transactions in callbacks more straightforward
2015-12-18 11:50:11 +01:00
Jinzhu e541ca5cdf Fix DropTableIfExists with string 2015-12-16 21:00:56 +08:00
Richard Knop 39e6f58111 There was still an issue with preloading and pointers.
This was actually broken with the refactoring. I added a test to catch
the other place the error was occuring. See the new
TestManyToManyPreloadForNestedPointer test in preload_test.go.
2015-12-16 17:30:58 +08:00
Jinzhu c6a22c5096 Refact fix invalid zero value for Preload 2015-12-16 10:40:57 +08:00
Jinzhu 861c477a33 Test Preload won't panic when nothing found 2015-12-16 10:35:22 +08:00
Jinzhu b2a66e79e8 Merge branch 'RichardKnop-bugfix/preload_indirect_zero_value_check' 2015-12-16 10:27:09 +08:00
Jinzhu 15169e635a Add two more nested many2many preload tests 2015-12-16 10:25:07 +08:00
Richard Knop e69ffaa9c4 Fixed a bug with invalid zero value in preload
When using pointers in model structs, there is an edge case.

When using preload to eagerly preload a many to many relationship and
the main row is not found by a primary key, use of reflect.Indirect in
preload.go results in a zero value and the subsequent call to
FieldByName panics the program.
2015-12-16 00:18:39 +08:00
Jinzhu ba694926d0 Create composite primary key for join table 2015-12-11 12:22:09 +08:00
Jinzhu 341703ed5d Scan value into ignored fields if there is no ambiguity 2015-12-11 11:45:22 +08:00
Jinzhu 8ee49893d1 Merge pull request #750 from lcowell/better_field_error
provide user with more descriptive error message
2015-12-09 10:44:54 +08:00
Jinzhu 807ed63cfe Fix pollute model's fields with join table's values 2015-12-09 10:40:12 +08:00
Luke Cowell fc42a1bbf3 provide user with more descriptive error message 2015-12-04 14:56:21 -08:00
Jinzhu 4c1a78bab7 Don't query all columns out from database after create, but only those has default value 2015-12-04 18:41:28 +08:00