Commit Graph

94 Commits

Author SHA1 Message Date
Jinzhu a00fb4db04 Add Delete support for has many associations 2015-12-25 18:42:26 +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 58596afda1 Replace many2many associations with empty 2015-09-30 21:30:58 +08:00
Jinzhu a480621b76 Fix extra updates when Append associations for many2many 2015-09-30 12:10:22 +08:00
Rahul Ghose 1c227d4243 this fixes syntax error
relevant issue: https://github.com/jinzhu/gorm/issues/588
2015-07-31 16:52:46 +05:30
Jinzhu f00b95d305 Passed all tests for multiple primary keys 2015-07-30 22:59:25 +08:00
Jinzhu ebbeecd10f Fix test TestManyToMany 2015-07-30 22:18:56 +08:00
Jinzhu dc428d2364 Fix compile error for association 2015-07-30 17:26:10 +08:00
Jinzhu d75612b86f Update JoinTableHandler API 2015-06-19 11:32:11 +08:00
Jinzhu 7e8622f671 Don't need to delete join table records if no record added 2015-06-18 18:23:11 +08:00
Jinzhu 1eb1ed091f Test ManyToMany relations with multi primary keys 2015-04-10 16:55:53 +08:00
Jinzhu 44b106c8e2 Fix tests 2015-03-19 18:23:54 +08:00
Jinzhu c13e2f18f8 New JoinTableHandler 2015-03-18 11:47:11 +08:00
Jinzhu 49454839bd Support Multi primary keys 2015-03-11 11:28:30 +08:00
Jinzhu 80576bbbbc Add Table method for JoinTableHandler 2015-03-04 13:56:47 +08:00
Jinzhu 6d64e6837b Add JoinTableHandler 2015-02-28 12:05:14 +08:00
Jinzhu 33e6b14632 Clear value from db after set table name 2015-02-26 16:08:26 +08:00
Jinzhu eb480cc085 Modify struct when update association 2015-02-24 18:48:48 +08:00
Jinzhu 0d2c37e310 Refactor Model Struct 2015-02-18 12:50:37 +08:00
Jinzhu 5c478b46e1 Use Common Initialisms from golint 2015-02-18 10:36:32 +08:00
Jinzhu 672ba4ffc9 Rename ToSnake to ToDBColumnName 2015-02-18 09:26:35 +08:00
Jinzhu 0b32041135 Review and Refactor 2015-02-17 22:55:14 +08:00
Jinzhu 38cbff9c79 Refactor Associations 2015-02-17 20:19:47 +08:00
Jinzhu 00d1187c4c Refactor Association 2015-02-17 19:17:21 +08:00
Jinzhu 2a8c7973cb Use new relationship API 2015-02-17 18:57:50 +08:00
Jinzhu f4e705b749 Fix compile error 2015-02-16 16:42:01 +08:00
Jinzhu 6864d5e5bd Add polymorphic_test.go 2015-02-13 11:26:02 +08:00
Jinzhu 8aef600540 Fix association Replace delete wrong records 2015-02-09 21:54:16 +08:00
Jinzhu b7554a2cb0 Fix delete many2many associations 2015-01-16 10:15:53 +08:00
jnfeinstein 8b451f0084 Add support for polymorphic relationships using the POLYMORPHIC setting.
This commit adds support for two settings:

FOREIGNTYPE - A field that is used to store the type of the owner.

POLYMORPHIC - A shortcut to set FOREIGNKEY and FOREIGNTYPE to the same
value suffixed by "Id" and "Type" respectively.

The type is stored as the table name, which I thought might be useful
for other queries.

The biggest gotcha of this commit is that I flipped the definition of
has_one and belongs_to. gorm is very flexible such that it didn't
really care if it was a has_one or belongs_to, and can pretty much
determine it at runtime. For the sake of the error, I had to define
one of them as belongs_to, and I chose the one with the fields as
the belongs_to, like ActiveRecord. The error could probably be
genericized to "gorm cannot determine type", but I think it's nicer
to tell people DONT DO PATTERN XYZ CAUSE IT WONT WORK. Functionally,
it doesn't matter.
2014-11-25 21:35:47 -08:00
jnfeinstein 794e1ba20b .Count() should always use ToSnake'd foreign keys.
It looks like gorm always uses the snake form of a column by
convention, as seen by searching DBName in scope.go. These counts
were erroring out without the ToSnake'd foreign keys.

Further, the code for has_many and has_one becomes the same (which
makes sense), so I combined the two cases.
2014-11-25 11:47:23 -08:00
Tristan Storch 9bee4239d4 FieldValueByName does now only what it should
FieldValueByName in utils.go does now only what it should and has proper errors.
2014-10-01 16:20:12 +02:00
Jinzhu 953c347ba7 Refactor Scope 2014-09-02 19:03:01 +08:00
Jinzhu 90106d82c5 Export Relationship 2014-07-31 14:38:16 +08:00
Jinzhu ba74a9545b Make clear works 2014-07-30 22:15:31 +08:00
Jinzhu 5a95050464 Make association replace works 2014-07-30 22:10:12 +08:00
Jinzhu db3da2c636 Make association Count works 2014-07-30 21:43:53 +08:00
Jinzhu 2356182ea7 Rename joinTable to relationship 2014-07-30 20:59:52 +08:00
Jinzhu e1e68debdc improve association 2014-07-30 20:48:36 +08:00
Jinzhu efd3b7678b Be able to find many to many relations 2014-07-30 16:22:26 +08:00
Jinzhu ba95de5c50 Rename relations to associations 2014-07-30 14:30:21 +08:00