希望可以支持一下JSONQuery("key").NotEquals(...)
Open
@jinzhu is already working on this.
Since Apr 28, 2024.
- Dominant language
- Go
- Stars
- 831
- Forks
- 124
- PR merge metrics
- No merged PRs in 30d
Description
我尝试着复制JSONQuery代码自己修改NotEquals,发现gorm框架里面有各种各样的类型限制,导致我没法直接设计自己的NotEquals
所以希望架构能支持JSONQuery.NotEquals, 或者说至少支持我自定义实现JSONQuery等部类型的相关Condition接口
func exprToCondition(exprs ...clause.Expression) []Condition {
conds := make([]Condition, 0, len(exprs))
for _, e := range exprs {
switch e := e.(type) {
case *datatypes.JSONQueryExpression, *datatypes.JSONOverlapsExpression:
conds = append(conds, &condContainer{value: e})
default:
conds = append(conds, &condContainer{err: fmt.Errorf("unsupported Expression %T to converted to Condition", e)})
}
}
return conds
}
func condToExpression(conds []Condition) ([]clause.Expression, error) {
if len(conds) == 0 {
return nil, nil
}
exprs := make([]clause.Expression, 0, len(conds))
for _, cond := range conds {
if cond == nil {
continue
}
if err := cond.CondError(); err != nil {
return nil, err
}
switch cond.(type) {
case *condContainer, field.Expr, SubQuery:
default:
return nil, fmt.Errorf("unsupported condition: %+v", cond)
}
switch e := cond.BeCond().(type) {
case []clause.Expression:
exprs = append(exprs, e...)
case clause.Expression:
exprs = append(exprs, e)
}
}
return exprs, nil
}
Motivation
Related Issues
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.