Commit Graph

25 Commits

Author SHA1 Message Date
Jinzhu d75612b86f Update JoinTableHandler API 2015-06-19 11:32:11 +08:00
Jay Taylor ab48cd222a `UpdateColumns(...)` no longer triggers save of associated records. 2015-03-28 14:15:12 -07:00
Jinzhu c13e2f18f8 New JoinTableHandler 2015-03-18 11:47:11 +08:00
Jinzhu 187eae8d9c Update with Select and Omit 2015-03-12 18:30:59 +08:00
Jinzhu ad251b9deb Create with Select 2015-03-12 17:47:31 +08:00
Jinzhu 6d64e6837b Add JoinTableHandler 2015-02-28 12:05:14 +08:00
Jinzhu a97a508ec7 Raise error if using unaddressable value 2015-02-23 09:40:39 +08:00
Jinzhu 0d2c37e310 Refactor Model Struct 2015-02-18 12:50:37 +08:00
Jinzhu 38cbff9c79 Refactor Associations 2015-02-17 20:19:47 +08:00
Jinzhu d6439f4147 Fix tests after refactor 2015-02-17 18:01:24 +08:00
Jinzhu 3a73206010 Refactor model struct 2015-02-16 16:35:26 +08:00
Jinzhu cbcb88d3d1 Fix set ForeignKey for embedded struct 2014-12-04 11:44:00 +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
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 df4a00a945 Update README with Associations 2014-07-30 22:50:27 +08:00
Jinzhu 6c4b635176 Replace BeforeAssociation, AfterAssociation with association type 2014-07-30 21:14:10 +08:00
Jinzhu 2356182ea7 Rename joinTable to relationship 2014-07-30 20:59:52 +08:00
Jinzhu 14590a65dc Save many to many relations into join table 2014-07-30 14:18:15 +08:00
Jinzhu a7aaf151cf Use JoinTable instead of ForeignKey 2014-07-30 11:32:18 +08:00
Jinzhu cb7d545ac0 Refact tests 2014-07-29 11:38:28 +08:00
Jinzhu 3981baf65d Make callback create pass all tests 2014-01-27 10:47:37 +08:00
Jinzhu ee6a6827a8 implement callback shared 2014-01-27 08:26:59 +08:00
Jinzhu 8dd7b4ed91 make callback create works 2014-01-26 19:36:15 +08:00
Jinzhu 261ece5696 Make callback delete works 2014-01-26 17:10:33 +08:00