Delete useless duplicate method.
This commit is contained in:
parent
005218d61f
commit
89ec1cfdb7
2 changed files with 0 additions and 32 deletions
|
@ -197,22 +197,6 @@ func SelectNames(results interface{}) string {
|
||||||
return strings.Join(names, ", ")
|
return strings.Join(names, ", ")
|
||||||
}
|
}
|
||||||
|
|
||||||
// WhereClause returns the where clause for an sql statement
|
|
||||||
// eg: "col1"=$1 AND "col2"=$2 AND "col3"=$3
|
|
||||||
func WhereClause(columns []string) string {
|
|
||||||
names := make([]string, 0, len(columns))
|
|
||||||
|
|
||||||
for _, c := range columns {
|
|
||||||
names = append(names, c)
|
|
||||||
}
|
|
||||||
|
|
||||||
for i, c := range names {
|
|
||||||
names[i] = fmt.Sprintf(`"%s"=$%d`, c, i+1)
|
|
||||||
}
|
|
||||||
|
|
||||||
return strings.Join(names, " AND ")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update returns the column list for an update statement SET clause
|
// Update returns the column list for an update statement SET clause
|
||||||
// eg: "col1"=$1, "col2"=$2, "col3"=$3
|
// eg: "col1"=$1, "col2"=$2, "col3"=$3
|
||||||
func Update(columns map[string]interface{}) string {
|
func Update(columns map[string]interface{}) string {
|
||||||
|
|
|
@ -308,19 +308,3 @@ func TestSelectNames(t *testing.T) {
|
||||||
t.Error("Result was wrong, got:", result)
|
t.Error("Result was wrong, got:", result)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestWhereClause(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
columns := []string{
|
|
||||||
"id",
|
|
||||||
"name",
|
|
||||||
"date",
|
|
||||||
}
|
|
||||||
|
|
||||||
result := WhereClause(columns)
|
|
||||||
|
|
||||||
if result != `"id"=$1 AND "name"=$2 AND "date"=$3` {
|
|
||||||
t.Error("Result was wrong, got:", result)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue