summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/go-xorm/builder/cond_compare.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/go-xorm/builder/cond_compare.go')
-rw-r--r--vendor/github.com/go-xorm/builder/cond_compare.go30
1 files changed, 25 insertions, 5 deletions
diff --git a/vendor/github.com/go-xorm/builder/cond_compare.go b/vendor/github.com/go-xorm/builder/cond_compare.go
index 54785d480a..e10ef7447c 100644
--- a/vendor/github.com/go-xorm/builder/cond_compare.go
+++ b/vendor/github.com/go-xorm/builder/cond_compare.go
@@ -1,8 +1,12 @@
+// Copyright 2016 The Xorm Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
package builder
import "fmt"
-// WriteMap
+// WriteMap writes conditions' SQL to Writer, op could be =, <>, >, <, <=, >= and etc.
func WriteMap(w Writer, data map[string]interface{}, op string) error {
var args = make([]interface{}, 0, len(data))
var i = 0
@@ -49,86 +53,102 @@ func WriteMap(w Writer, data map[string]interface{}, op string) error {
return nil
}
-// Lt
+// Lt defines < condition
type Lt map[string]interface{}
var _ Cond = Lt{}
+// WriteTo write SQL to Writer
func (lt Lt) WriteTo(w Writer) error {
return WriteMap(w, lt, "<")
}
+// And implements And with other conditions
func (lt Lt) And(conds ...Cond) Cond {
return condAnd{lt, And(conds...)}
}
+// Or implements Or with other conditions
func (lt Lt) Or(conds ...Cond) Cond {
return condOr{lt, Or(conds...)}
}
+// IsValid tests if this Eq is valid
func (lt Lt) IsValid() bool {
return len(lt) > 0
}
-// Lte
+// Lte defines <= condition
type Lte map[string]interface{}
var _ Cond = Lte{}
+// WriteTo write SQL to Writer
func (lte Lte) WriteTo(w Writer) error {
return WriteMap(w, lte, "<=")
}
+// And implements And with other conditions
func (lte Lte) And(conds ...Cond) Cond {
return And(lte, And(conds...))
}
+// Or implements Or with other conditions
func (lte Lte) Or(conds ...Cond) Cond {
return Or(lte, Or(conds...))
}
+// IsValid tests if this Eq is valid
func (lte Lte) IsValid() bool {
return len(lte) > 0
}
-// Gt
+// Gt defines > condition
type Gt map[string]interface{}
var _ Cond = Gt{}
+// WriteTo write SQL to Writer
func (gt Gt) WriteTo(w Writer) error {
return WriteMap(w, gt, ">")
}
+// And implements And with other conditions
func (gt Gt) And(conds ...Cond) Cond {
return And(gt, And(conds...))
}
+// Or implements Or with other conditions
func (gt Gt) Or(conds ...Cond) Cond {
return Or(gt, Or(conds...))
}
+// IsValid tests if this Eq is valid
func (gt Gt) IsValid() bool {
return len(gt) > 0
}
-// Gte
+// Gte defines >= condition
type Gte map[string]interface{}
var _ Cond = Gte{}
+// WriteTo write SQL to Writer
func (gte Gte) WriteTo(w Writer) error {
return WriteMap(w, gte, ">=")
}
+// And implements And with other conditions
func (gte Gte) And(conds ...Cond) Cond {
return And(gte, And(conds...))
}
+// Or implements Or with other conditions
func (gte Gte) Or(conds ...Cond) Cond {
return Or(gte, Or(conds...))
}
+// IsValid tests if this Eq is valid
func (gte Gte) IsValid() bool {
return len(gte) > 0
}