mirror of https://github.com/go-gorm/gorm.git
Passed all tests
This commit is contained in:
parent
44b106c8e2
commit
9af0563496
|
@ -42,7 +42,7 @@ func (*PersonAddress) Delete(db *gorm.DB, sources ...interface{}) error {
|
||||||
|
|
||||||
func (pa *PersonAddress) JoinWith(db *gorm.DB, source interface{}) *gorm.DB {
|
func (pa *PersonAddress) JoinWith(db *gorm.DB, source interface{}) *gorm.DB {
|
||||||
table := pa.Table(db)
|
table := pa.Table(db)
|
||||||
return db.Table(table).Where(fmt.Sprintf("%v.deleted_at IS NULL OR %v.deleted_at <= '0001-01-02'", table, table))
|
return db.Table(table).Joins("INNER JOIN person_addresses ON person_addresses.address_id = addresses.id").Where(fmt.Sprintf("%v.deleted_at IS NULL OR %v.deleted_at <= '0001-01-02'", table, table))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestJoinTable(t *testing.T) {
|
func TestJoinTable(t *testing.T) {
|
||||||
|
@ -61,7 +61,7 @@ func TestJoinTable(t *testing.T) {
|
||||||
t.Errorf("Should found one address")
|
t.Errorf("Should found one address")
|
||||||
}
|
}
|
||||||
|
|
||||||
if DB.Debug().Model(person).Association("Addresses").Count() != 1 {
|
if DB.Model(person).Association("Addresses").Count() != 1 {
|
||||||
t.Errorf("Should found one address")
|
t.Errorf("Should found one address")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue