50 lines
1016 B
Go
50 lines
1016 B
Go
package adapter
|
|
|
|
// RawExpr interface represents values that can bypass SQL filters. This is an
|
|
// exported interface but it's rarely used directly, you may want to use the
|
|
// `db.Raw()` function instead.
|
|
type RawExpr struct {
|
|
value string
|
|
args *[]interface{}
|
|
}
|
|
|
|
func (r *RawExpr) Arguments() []interface{} {
|
|
if r.args != nil {
|
|
return *r.args
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (r RawExpr) Raw() string {
|
|
return r.value
|
|
}
|
|
|
|
func (r RawExpr) String() string {
|
|
return r.Raw()
|
|
}
|
|
|
|
// Expressions returns a logical expressio.n
|
|
func (r *RawExpr) Expressions() []LogicalExpr {
|
|
return []LogicalExpr{r}
|
|
}
|
|
|
|
// Operator returns the default compound operator.
|
|
func (r RawExpr) Operator() LogicalOperator {
|
|
return LogicalOperatorNone
|
|
}
|
|
|
|
// Empty return false if this struct has no value.
|
|
func (r *RawExpr) Empty() bool {
|
|
return r.value == ""
|
|
}
|
|
|
|
func NewRawExpr(value string, args []interface{}) *RawExpr {
|
|
r := &RawExpr{value: value, args: nil}
|
|
if len(args) > 0 {
|
|
r.args = &args
|
|
}
|
|
return r
|
|
}
|
|
|
|
var _ = LogicalExpr(&RawExpr{})
|