From 851ba9de30496ee475f7d70d51eaace38450ce38 Mon Sep 17 00:00:00 2001 From: Jordan Date: Wed, 28 May 2014 22:20:58 -0500 Subject: [PATCH] Fixed double insertion of results when worker handles campaign (looks like a bug in gorm) Removed handy abbreviation due to latest commit in gorm (this is why we can't have nice things :smile) --- models/campaign.go | 3 ++- models/group.go | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/models/campaign.go b/models/campaign.go index beabfe7d..3c04ec51 100644 --- a/models/campaign.go +++ b/models/campaign.go @@ -89,7 +89,8 @@ func PostCampaign(c *Campaign, uid int64) error { } func UpdateCampaignStatus(c *Campaign, s string) error { - return db.Model(c).UpdateColumn("status", s).Error + // This could be made simpler, but I think there's a bug in gorm + return db.Debug().Table("campaigns").Where("id=?", c.Id).Update("status", s).Error } //DeleteCampaign deletes the specified campaign diff --git a/models/group.go b/models/group.go index dc80c501..c53cf37d 100644 --- a/models/group.go +++ b/models/group.go @@ -189,6 +189,6 @@ func insertTargetIntoGroup(t Target, gid int64) error { func GetTargets(gid int64) ([]Target, error) { ts := []Target{} - err := db.Table("targets t").Select("t.id, t.email").Joins("left join group_targets gt ON t.id = gt.target_id").Where("gt.group_id=?", gid).Scan(&ts).Error + err := db.Table("targets").Select("targets.id, targets.email").Joins("left join group_targets gt ON targets.id = gt.target_id").Where("gt.group_id=?", gid).Scan(&ts).Error return ts, err }