From 9af056349670e100e76a572f31adb681205fd8b6 Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Thu, 19 Mar 2015 18:30:35 +0800 Subject: [PATCH] Passed all tests --- join_table_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/join_table_test.go b/join_table_test.go index 38e9f943..40f36799 100644 --- a/join_table_test.go +++ b/join_table_test.go @@ -42,7 +42,7 @@ func (*PersonAddress) Delete(db *gorm.DB, sources ...interface{}) error { func (pa *PersonAddress) JoinWith(db *gorm.DB, source interface{}) *gorm.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) { @@ -61,7 +61,7 @@ func TestJoinTable(t *testing.T) { 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") }