mirror of https://github.com/adamdruppe/arsd.git
Added constructor to Query to allow dynamically generated args.
(It takes a Variant[] array)
This commit is contained in:
parent
b6cf1009c1
commit
27623f0d72
10
database.d
10
database.d
|
@ -61,11 +61,13 @@ Ret queryOneColumn(Ret, T...)(Database db, string sql, T t) {
|
||||||
|
|
||||||
struct Query {
|
struct Query {
|
||||||
ResultSet result;
|
ResultSet result;
|
||||||
static Query opCall(T...)(Database db, string sql, T t) {
|
this(T...)(Database db, string sql, T t) if(T.length!=1 || !is(T[0]==Variant[])) {
|
||||||
Query q;
|
result = db.query(sql, t);
|
||||||
q.result = db.query(sql, t);
|
|
||||||
return q;
|
|
||||||
}
|
}
|
||||||
|
// Version for dynamic generation of args: (Needs to be a template for coexistence with other constructor.
|
||||||
|
this(T...)(Database db, string sql, T args) if (T.length==1 && is(T[0] == Variant[])) {
|
||||||
|
result = db.queryImpl(sql, args);
|
||||||
|
}
|
||||||
|
|
||||||
int opApply(T)(T dg) if(is(T == delegate)) {
|
int opApply(T)(T dg) if(is(T == delegate)) {
|
||||||
import std.traits;
|
import std.traits;
|
||||||
|
|
Loading…
Reference in New Issue