Skip to content

Field 支持自定义字段,如:NewRawField(sql string,vars ...interface{}) #1212

@mimicode

Description

@mimicode

Describe the feature

通过如下方法实现自定义字段
var customCol1 = field.NewFieldRaw("IF(column1='1',column1,?)","456")
var customCol2 = field.NewFieldRaw("case column2 when ? then ? else ? end","1","正常","异常")
query.Table1.Select(customCol1,customCol2,query.Table1.Column2).Order(customCol1.Desc()).Where(customCol2.Eq(value))

Motivation

select 时需要自定义字段
order by 时 需要通过自定义字段进行排序
where 时 需要通过自定义字段筛选

Related Issues

#1113
#1028

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions