forked from mirror/gorm
Rename relations to associations
This commit is contained in:
parent
371e6af99e
commit
ba95de5c50
|
@ -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
|
||||
}
|
|
@ -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")
|
||||
}
|
5
main.go
5
main.go
|
@ -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
many2many.go
23
many2many.go
|
@ -1,23 +0,0 @@
|
|||
package gorm
|
||||
|
||||
type many2many struct {
|
||||
}
|
||||
|
||||
func (*many2many) Find(value interface{}) {
|
||||
}
|
||||
|
||||
func (*many2many) Append(values interface{}) {
|
||||
}
|
||||
|
||||
func (*many2many) Delete(value interface{}) {
|
||||
}
|
||||
|
||||
func (*many2many) Clear(value interface{}) {
|
||||
}
|
||||
|
||||
func (*many2many) Replace(values interface{}) {
|
||||
}
|
||||
|
||||
func (*many2many) Count(values interface{}) int {
|
||||
return 0
|
||||
}
|
Loading…
Reference in New Issue