Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mimicode opened this issue Sep 13, 2024 · 1 comment

Comments

@mimicode
Copy link

mimicode commented Sep 13, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant