|
@@ -26,7 +26,7 @@ func (conditions *Conditions) Equal(columnName string, arg any) *Conditions {
|
|
|
return conditions
|
|
|
}
|
|
|
|
|
|
- conditions.queries = append(conditions.queries, columnName+" = ?")
|
|
|
+ conditions.appendQuery(columnName, " = ?")
|
|
|
conditions.args = append(conditions.args, []any{arg})
|
|
|
return conditions
|
|
|
}
|
|
@@ -36,7 +36,7 @@ func (conditions *Conditions) Like(columnName string, arg string) *Conditions {
|
|
|
return conditions
|
|
|
}
|
|
|
|
|
|
- conditions.queries = append(conditions.queries, columnName+" LIKE ?")
|
|
|
+ conditions.appendQuery(columnName, " LIKE ?")
|
|
|
conditions.args = append(conditions.args, []any{arg})
|
|
|
return conditions
|
|
|
}
|
|
@@ -46,7 +46,7 @@ func (conditions *Conditions) In(columnName string, arg any) *Conditions {
|
|
|
return conditions
|
|
|
}
|
|
|
|
|
|
- conditions.queries = append(conditions.queries, columnName+" IN ?")
|
|
|
+ conditions.appendQuery(columnName, " IN ?")
|
|
|
conditions.args = append(conditions.args, []any{arg})
|
|
|
return conditions
|
|
|
}
|
|
@@ -56,7 +56,7 @@ func (conditions *Conditions) NotIn(columnName string, arg any) *Conditions {
|
|
|
return conditions
|
|
|
}
|
|
|
|
|
|
- conditions.queries = append(conditions.queries, columnName+" NOT IN ?")
|
|
|
+ conditions.appendQuery(columnName, " NOT IN ?")
|
|
|
conditions.args = append(conditions.args, []any{arg})
|
|
|
return conditions
|
|
|
}
|
|
@@ -66,7 +66,7 @@ func (conditions *Conditions) Not(columnName string, arg any) *Conditions {
|
|
|
return conditions
|
|
|
}
|
|
|
|
|
|
- conditions.queries = append(conditions.queries, columnName+" != ?")
|
|
|
+ conditions.appendQuery(columnName, " != ?")
|
|
|
conditions.args = append(conditions.args, []any{arg})
|
|
|
return conditions
|
|
|
}
|
|
@@ -76,7 +76,7 @@ func (conditions *Conditions) LessThan(columnName string, arg any) *Conditions {
|
|
|
return conditions
|
|
|
}
|
|
|
|
|
|
- conditions.queries = append(conditions.queries, columnName+" < ?")
|
|
|
+ conditions.appendQuery(columnName, " < ?")
|
|
|
conditions.args = append(conditions.args, []any{arg})
|
|
|
return conditions
|
|
|
}
|
|
@@ -86,7 +86,7 @@ func (conditions *Conditions) LessThanAndEqual(columnName string, arg any) *Cond
|
|
|
return conditions
|
|
|
}
|
|
|
|
|
|
- conditions.queries = append(conditions.queries, columnName+" <= ?")
|
|
|
+ conditions.appendQuery(columnName, " <= ?")
|
|
|
conditions.args = append(conditions.args, []any{arg})
|
|
|
return conditions
|
|
|
}
|
|
@@ -96,7 +96,7 @@ func (conditions *Conditions) GreaterThan(columnName string, arg any) *Condition
|
|
|
return conditions
|
|
|
}
|
|
|
|
|
|
- conditions.queries = append(conditions.queries, columnName+" > ?")
|
|
|
+ conditions.appendQuery(columnName, " > ?")
|
|
|
conditions.args = append(conditions.args, []any{arg})
|
|
|
return conditions
|
|
|
}
|
|
@@ -106,7 +106,7 @@ func (conditions *Conditions) GreaterThanAndEqual(columnName string, arg any) *C
|
|
|
return conditions
|
|
|
}
|
|
|
|
|
|
- conditions.queries = append(conditions.queries, columnName+" >= ?")
|
|
|
+ conditions.appendQuery(columnName, " >= ?")
|
|
|
conditions.args = append(conditions.args, []any{arg})
|
|
|
return conditions
|
|
|
}
|
|
@@ -119,6 +119,10 @@ func (conditions *Conditions) Or() *Or {
|
|
|
return &Or{conditions: conditions}
|
|
|
}
|
|
|
|
|
|
+func (conditions *Conditions) appendQuery(columnName string, expr string) {
|
|
|
+ conditions.queries = append(conditions.queries, `"`+columnName+`"`+expr)
|
|
|
+}
|
|
|
+
|
|
|
func (conditions *Conditions) formClause(conditionOperator string) (string, error) {
|
|
|
if conditions.queries == nil || len(conditions.queries) == 0 {
|
|
|
return "", nil
|