adds support for named arguments in select
This commit is contained in:
parent
a948c84607
commit
5ad4e6ee98
@ -93,7 +93,12 @@ func (db *DB) Select(query interface{}, args ...interface{}) (tx *DB) {
|
|||||||
}
|
}
|
||||||
delete(tx.Statement.Clauses, "SELECT")
|
delete(tx.Statement.Clauses, "SELECT")
|
||||||
case string:
|
case string:
|
||||||
if strings.Count(v, "?") >= len(args) && len(args) > 0 {
|
if strings.Count(v, "@") <= len(args) && len(args) > 0 {
|
||||||
|
tx.Statement.AddClause(clause.Select{
|
||||||
|
Distinct: db.Statement.Distinct,
|
||||||
|
Expression: clause.NamedExpr{SQL: v, Vars: args},
|
||||||
|
})
|
||||||
|
} else if strings.Count(v, "?") >= len(args) && len(args) > 0 {
|
||||||
tx.Statement.AddClause(clause.Select{
|
tx.Statement.AddClause(clause.Select{
|
||||||
Distinct: db.Statement.Distinct,
|
Distinct: db.Statement.Distinct,
|
||||||
Expression: clause.Expr{SQL: v, Vars: args},
|
Expression: clause.Expr{SQL: v, Vars: args},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user