Skip to content

Commit

Permalink
Rename relations to associations
Browse files Browse the repository at this point in the history
  • Loading branch information
jinzhu committed Jul 30, 2014
1 parent 371e6af commit ba95de5
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 26 deletions.
25 changes: 25 additions & 0 deletions association.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package gorm

type Association struct {
Scope *Scope
Column string
}

func (*Association) Find(value interface{}) {
}

func (*Association) Append(values interface{}) {
}

func (*Association) Delete(value interface{}) {
}

func (*Association) Clear(value interface{}) {
}

func (*Association) Replace(values interface{}) {
}

func (*Association) Count(values interface{}) int {
return 0
}
2 changes: 1 addition & 1 deletion relations_test.go → association_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func TestQueryManyToManyWithRelated(t *testing.T) {
// }

newLanguages = []Language{}
db.Model(&user).Many2Many("Languages").Find(&newLanguages)
db.Model(&user).Association("Languages").Find(&newLanguages)
if len(newLanguages) != 3 {
t.Errorf("Query many to many relations")
}
Expand Down
5 changes: 3 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ func (s *DB) RemoveIndex(indexName string) *DB {
return s
}

func (s *DB) Many2Many(column string) *DB {
return s
func (s *DB) Association(column string) *Association {
scope := s.clone().NewScope(s.Value)
return &Association{Scope: scope, Column: column}
}
23 changes: 0 additions & 23 deletions many2many.go

This file was deleted.

0 comments on commit ba95de5

Please sign in to comment.