Skip to content

Commit 40b950a

Browse files
committed
## 0.2.0-beta7 fix where @raw的处理
1 parent 8904741 commit 40b950a

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

drivers/goframe/executor/action.go

+12-3
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func (a *ActionExecutor) Update(ctx context.Context, table string, data model.Ma
9797
continue
9898
}
9999

100-
if v == nil || gconv.String(v) == "" { //暂只处理字符串为空的情况
100+
if v == nil || gconv.String(v) == "" { // 暂只处理字符串为空的情况
101101
return nil, gerror.New("where的值不能为空:" + k)
102102
}
103103
}
@@ -149,17 +149,26 @@ func (a *ActionExecutor) Delete(ctx context.Context, table string, where model.M
149149
m := g.DB(a.DbName).Model(table).Ctx(ctx)
150150

151151
for k, v := range where {
152+
153+
if k == "@raw" {
154+
m = m.Where(v)
155+
continue
156+
}
157+
152158
if strings.HasSuffix(k, "{}") {
153159
m = m.WhereIn(k[0:len(k)-2], v)
154160
delete(where, k)
155161
continue
156162
}
157-
if v.(string) == "" || v == nil { //暂只处理字符串为空的情况
163+
164+
if gconv.String(v) == "" || v == nil { // 暂只处理字符串为空的情况
158165
return nil, gerror.New("where的值不能为空")
159166
}
167+
168+
m = m.Where(k, v)
160169
}
161170

162-
_ret, err := m.Where(where).Delete()
171+
_ret, err := m.Delete()
163172
if err != nil {
164173
return nil, err
165174
}

drivers/goframe/executor/query.go

+4
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ func (e *SqlExecutor) ParseCondition(conditions model.MapStrAny, accessVerify bo
8989
k := dbStyle(e.ctx, tableName, where[0].(string))
9090
if val, exists := inFieldsMap[k]; exists {
9191

92+
if len(val) == 0 {
93+
continue
94+
}
95+
9296
if val[0] == "*" {
9397
continue
9498
}

0 commit comments

Comments
 (0)