Seperator -> Separator
This commit is contained in:
parent
f6d113a5ef
commit
0b7e6fc507
4 changed files with 11 additions and 11 deletions
|
@ -224,7 +224,7 @@ func Update(columns map[string]interface{}) string {
|
||||||
return strings.Join(names, ", ")
|
return strings.Join(names, ", ")
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetParamNames takes a slice of columns and returns a comma seperated
|
// SetParamNames takes a slice of columns and returns a comma separated
|
||||||
// list of parameter names for a template statement SET clause.
|
// list of parameter names for a template statement SET clause.
|
||||||
// eg: "col1"=$1, "col2"=$2, "col3"=$3
|
// eg: "col1"=$1, "col2"=$2, "col3"=$3
|
||||||
func SetParamNames(columns []string) string {
|
func SetParamNames(columns []string) string {
|
||||||
|
|
|
@ -36,7 +36,7 @@ type Query struct {
|
||||||
|
|
||||||
type where struct {
|
type where struct {
|
||||||
clause string
|
clause string
|
||||||
orSeperator bool
|
orSeparator bool
|
||||||
args []interface{}
|
args []interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,9 +180,9 @@ func SetWhere(q *Query, clause string, args ...interface{}) {
|
||||||
q.where = append([]where(nil), where{clause: clause, args: args})
|
q.where = append([]where(nil), where{clause: clause, args: args})
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetLastWhereAsOr sets the or seperator for the last element in the where slice
|
// SetLastWhereAsOr sets the or separator for the last element in the where slice
|
||||||
func SetLastWhereAsOr(q *Query) {
|
func SetLastWhereAsOr(q *Query) {
|
||||||
q.where[len(q.where)-1].orSeperator = true
|
q.where[len(q.where)-1].orSeparator = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// ApplyGroupBy on the query.
|
// ApplyGroupBy on the query.
|
||||||
|
|
|
@ -180,7 +180,7 @@ func whereClause(q *Query) (string, []interface{}) {
|
||||||
if i >= len(q.where)-1 {
|
if i >= len(q.where)-1 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if q.where[i].orSeperator {
|
if q.where[i].orSeparator {
|
||||||
buf.WriteString(" OR ")
|
buf.WriteString(" OR ")
|
||||||
} else {
|
} else {
|
||||||
buf.WriteString(" AND ")
|
buf.WriteString(" AND ")
|
||||||
|
|
|
@ -12,8 +12,8 @@ func TestSetLastWhereAsOr(t *testing.T) {
|
||||||
|
|
||||||
AppendWhere(q, "")
|
AppendWhere(q, "")
|
||||||
|
|
||||||
if q.where[0].orSeperator {
|
if q.where[0].orSeparator {
|
||||||
t.Errorf("Do not want or seperator")
|
t.Errorf("Do not want or separator")
|
||||||
}
|
}
|
||||||
|
|
||||||
SetLastWhereAsOr(q)
|
SetLastWhereAsOr(q)
|
||||||
|
@ -21,8 +21,8 @@ func TestSetLastWhereAsOr(t *testing.T) {
|
||||||
if len(q.where) != 1 {
|
if len(q.where) != 1 {
|
||||||
t.Errorf("Want len 1")
|
t.Errorf("Want len 1")
|
||||||
}
|
}
|
||||||
if !q.where[0].orSeperator {
|
if !q.where[0].orSeparator {
|
||||||
t.Errorf("Want or seperator")
|
t.Errorf("Want or separator")
|
||||||
}
|
}
|
||||||
|
|
||||||
AppendWhere(q, "")
|
AppendWhere(q, "")
|
||||||
|
@ -31,10 +31,10 @@ func TestSetLastWhereAsOr(t *testing.T) {
|
||||||
if len(q.where) != 2 {
|
if len(q.where) != 2 {
|
||||||
t.Errorf("Want len 2")
|
t.Errorf("Want len 2")
|
||||||
}
|
}
|
||||||
if q.where[0].orSeperator != true {
|
if q.where[0].orSeparator != true {
|
||||||
t.Errorf("Expected true")
|
t.Errorf("Expected true")
|
||||||
}
|
}
|
||||||
if q.where[1].orSeperator != true {
|
if q.where[1].orSeparator != true {
|
||||||
t.Errorf("Expected true")
|
t.Errorf("Expected true")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue