From 9b01b1c63d6f6dfd722d315d29dbaf86c78b2e05 Mon Sep 17 00:00:00 2001 From: guanly Date: Thu, 11 May 2017 14:49:01 +0800 Subject: [PATCH 1/2] =?UTF-8?q?ISSUE2630=20=20=E4=BD=BF=E7=94=A8sqlite?= =?UTF-8?q?=EF=BC=8Corm=E4=B8=AD=E9=80=9A=E8=BF=87filter=E5=90=8E=E7=9A=84?= =?UTF-8?q?delete=E5=88=A0=E9=99=A4=E4=B8=8D=E6=88=90=E5=8A=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/astaxie/beego/issues/2630 --- orm/db.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/orm/db.go b/orm/db.go index 2a05797a..21030eef 100644 --- a/orm/db.go +++ b/orm/db.go @@ -833,7 +833,11 @@ func (d *dbBase) DeleteBatch(q dbQuerier, qs *querySet, mi *modelInfo, cond *Con if err := rs.Scan(&ref); err != nil { return 0, err } - args = append(args, reflect.ValueOf(ref).Interface()) + pkValue, err := d.convertValueFromDB(mi.fields.pk, reflect.ValueOf(ref).Interface(), tz) + if err != nil { + panic(fmt.Errorf("get pk value failed: `%s` ", ref)) + } + args = append(args, pkValue) cnt++ } From 10cd1070f45ceda87c19519e00b11e0ad1227ffd Mon Sep 17 00:00:00 2001 From: guanly Date: Thu, 11 May 2017 21:45:38 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BD=BF=E7=94=A8sqlite=EF=BC=8Corm?= =?UTF-8?q?=E4=B8=AD=E9=80=9A=E8=BF=87filter=E5=90=8E=E7=9A=84delete?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E4=B8=8D=E6=88=90=E5=8A=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/astaxie/beego/issues/2630 --- orm/db.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/orm/db.go b/orm/db.go index 21030eef..12f0f54d 100644 --- a/orm/db.go +++ b/orm/db.go @@ -835,7 +835,7 @@ func (d *dbBase) DeleteBatch(q dbQuerier, qs *querySet, mi *modelInfo, cond *Con } pkValue, err := d.convertValueFromDB(mi.fields.pk, reflect.ValueOf(ref).Interface(), tz) if err != nil { - panic(fmt.Errorf("get pk value failed: `%s` ", ref)) + return 0, err } args = append(args, pkValue) cnt++