mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
pg: update optional return syntax
This commit is contained in:
parent
896f978b94
commit
f1f720cc78
@ -103,14 +103,14 @@ pub fn (db DB) exec(query string) []pg.Row {
|
|||||||
return res_to_rows(res)
|
return res_to_rows(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn rows_first_or_empty(rows []pg.Row) pg.Row? {
|
fn rows_first_or_empty(rows []pg.Row) ?pg.Row {
|
||||||
if rows.len == 0 {
|
if rows.len == 0 {
|
||||||
return error('no row')
|
return error('no row')
|
||||||
}
|
}
|
||||||
return rows[0]
|
return rows[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (db DB) exec_one(query string) pg.Row? {
|
pub fn (db DB) exec_one(query string) ?pg.Row {
|
||||||
res := C.PQexec(db.conn, query.str)
|
res := C.PQexec(db.conn, query.str)
|
||||||
e := string(C.PQerrorMessage(db.conn))
|
e := string(C.PQerrorMessage(db.conn))
|
||||||
if e != '' {
|
if e != '' {
|
||||||
|
Loading…
Reference in New Issue
Block a user