mirror of
https://github.com/adamdruppe/arsd.git
synced 2025-04-27 13:50:00 +03:00
catching up on random stuff
This commit is contained in:
parent
4ff49846d4
commit
79b2a25b92
8 changed files with 334 additions and 39 deletions
10
mysql.d
10
mysql.d
|
@ -699,16 +699,22 @@ Ret queryOneRow(Ret = Row, DB, string file = __FILE__, size_t line = __LINE__, T
|
|||
static if(is(Ret : DataObject) && is(DB == MySql)) {
|
||||
auto res = db.queryDataObject!Ret(sql, t);
|
||||
if(res.empty)
|
||||
throw new Exception("result was empty", file, line);
|
||||
throw new EmptyResultException("result was empty", file, line);
|
||||
return res.front;
|
||||
} else static if(is(Ret == Row)) {
|
||||
auto res = db.query(sql, t);
|
||||
if(res.empty)
|
||||
throw new Exception("result was empty", file, line);
|
||||
throw new EmptyResultException("result was empty", file, line);
|
||||
return res.front;
|
||||
} else static assert(0, "Unsupported single row query return value, " ~ Ret.stringof);
|
||||
}
|
||||
|
||||
class EmptyResultException : Exception {
|
||||
this(string message, string file = __FILE__, size_t line = __LINE__) {
|
||||
super(message, file, line);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
void main() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue