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

我觉得expr.setE 方法可以公开,还有field.NewField支持raw #1219

Open
serious-snow opened this issue Sep 24, 2024 · 1 comment
Open

Comments

@serious-snow
Copy link

serious-snow commented Sep 24, 2024

Describe the feature

  1. 假设要自定义排序。
q.ReplaceDB(q.UnderlyingDB().Clauses(clause.OrderBy{
	Expression: clause.Expr{SQL: "? ASC NULLS FIRST", Vars: []any{someTable.SomeColumn}},
}))

这样不很奇怪吗? 我还要去使用gorm.DB, 那我用gen做什么呢?希望把expr.setE改为公开的方法。

我建议加一个方法

func (e expr) SetE(expression clause.Expression) expr {
	return e.setE(expression)
}
  1. field.NewField 自定义字段,强制Raw为false,导致编译的SQL有引号,不能正常使用
	banColumnRaw Option = func(col clause.Column) clause.Column {
		col.Raw = false
		return col
	}

gorm.DB能做的, gen还要去阻止。

Motivation

用户已经有这个需求了,既然去建议用户用gorm.DB去折中实现,为什么不能把gen放开一点呢。
也是为了开发便利,希望开发者能考虑一下。

Related Issues

(#1212)

@mimicode
Copy link

#1213

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

2 participants