initial commit
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
package simql
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type OnClause struct {
|
||||
column string
|
||||
operator string
|
||||
value any
|
||||
|
||||
and []*OnClause
|
||||
}
|
||||
|
||||
func (o *OnClause) And(column, operator string, value any) *OnClause {
|
||||
o.and = append(o.and, On(column, operator, value))
|
||||
return o
|
||||
}
|
||||
|
||||
func (o *OnClause) String() string {
|
||||
strs := []string{fmt.Sprintf("%s %s %s", o.column, o.operator, o.value)}
|
||||
|
||||
for _, next := range o.and {
|
||||
strs = append(strs, "and", next.String())
|
||||
}
|
||||
|
||||
return strings.Join(strs, " ")
|
||||
}
|
||||
|
||||
func On(column, operator string, value any) *OnClause {
|
||||
o := &OnClause{
|
||||
column: column,
|
||||
operator: operator,
|
||||
value: value,
|
||||
|
||||
and: []*OnClause{},
|
||||
}
|
||||
|
||||
return o
|
||||
}
|
||||
Reference in New Issue
Block a user