ecodeclub / eorm

简单 ORM 框架
Apache License 2.0
194 stars 64 forks source link

Predicates Support #11

Closed flycash closed 2 years ago

flycash commented 3 years ago

English Only

Please check existing issues first to avoid duplication and answer the questions below before submitting your issue.

Use case(s)

(Please state use cases, what problem will this feature solve?)

Predicates are used to filter rows. Predicate can be used in WHERE clause.

Proposed Solution

(Please describe your proposed design/solution, if any) Here are the major APIs and you can find them in predicate.go:

// P creates a Predicate
// left could be string or Expr
func P(left interface{}) Predicate {
    panic("implement me")
}

// Not indicates "NOT"
func Not(p Predicate) Predicate {
    panic("implement me")
}

// And indicates "AND"
func (p Predicate) And(pred Predicate) Predicate {
    panic("implement me")
}

// Or indicates "OR"
func (p Predicate) Or(pred Predicate) Predicate {
    panic("implement me")
}

// EQ =
func (p Predicate) EQ(val interface{}) Predicate {
    panic("implement")
}

// LT <
func (p Predicate) LT(val interface{}) Predicate {
    panic("implement me")
}

// GT >
func (p Predicate) GT(val interface{}) Predicate {
    panic("implement me")
}

But the most important things is to convert the predicates to string. For example:

P("id").LT(10)// `id` < 10

Alternatives Considered

(Other possible options for solving the problem?)

Additional Context

It relies on #10

(Paste any relevant logs - please use code blocks (```) to format console output, logs, and code as it's very hard to read otherwise.)

(If you can, link to the line of code that might be helpful to explain the context)

flycash commented 3 years ago

For this issue, we don't need to support complicate expression, we just support simple comparison.

xingjigongsi commented 3 years ago

ok,I will complete this method

github-actions[bot] commented 2 years ago

This issue is inactive for a long time.