feat: 升级 samber/do v1 → v2

This commit is contained in:
2026-05-15 09:04:12 +08:00
parent 7741f7584d
commit 9ad5d25836
47 changed files with 1456 additions and 684 deletions
+7 -8
View File
@@ -5,7 +5,6 @@ import (
"strings"
"unicode"
"git.fsdpf.net/go/contracts/res_type"
"git.fsdpf.net/go/db"
"git.fsdpf.net/go/req"
)
@@ -67,13 +66,13 @@ func (this *QueryField) ToSql() db.Expression {
if this.Alias() != "" {
if this.IsExpr() {
if this.GetCode() == "" {
return db.Raw("null as `" + this.Alias() + "`")
return db.V(nil).As(this.Alias())
}
return db.Raw("(" + this.GetCode() + ") as `" + this.Alias() + "`")
return db.L(this.GetCode()).As(this.Alias())
}
return db.Raw("`" + this.GetCodeResource() + "`.`" + this.GetCode() + "` as `" + this.Alias() + "`")
return db.T(this.GetCodeResource()).Col(this.GetCode()).As(this.Alias())
}
return db.Raw("`" + this.GetCodeResource() + "`.`" + this.GetCode() + "`")
return db.T(this.GetCodeResource()).Col(this.GetCode())
}
func (this *QueryField) ToStructField(tags ...string) reflect.StructField {
@@ -104,11 +103,11 @@ func (this *QueryField) ToStructField(tags ...string) reflect.StructField {
case req.ReqString:
typ = reflect.TypeOf(string(""))
case req.ReqNumber:
typ = reflect.TypeOf(res_type.ResFieldByNumber(0))
typ = reflect.TypeOf(float64(0))
case req.ReqInteger:
typ = reflect.TypeOf(res_type.ResFieldByInteger(0))
typ = reflect.TypeOf(int64(0))
case req.ReqFloat:
typ = reflect.TypeOf(res_type.ResFieldByFloat(0))
typ = reflect.TypeOf(float64(0))
case req.ReqBool:
typ = reflect.TypeOf(true)
case req.ReqArray: