mirror of
https://github.com/vlang/v.git
synced 2025-09-16 07:52:32 +03:00
db, json, time, term: change optional to result (#16201)
This commit is contained in:
parent
2a7420f572
commit
992b502198
57 changed files with 340 additions and 340 deletions
|
@ -106,7 +106,7 @@ fn C.sqlite3_errmsg(&C.sqlite3) &char
|
|||
fn C.sqlite3_free(voidptr)
|
||||
|
||||
// connect Opens the connection with a database.
|
||||
pub fn connect(path string) ?DB {
|
||||
pub fn connect(path string) !DB {
|
||||
db := &C.sqlite3(0)
|
||||
code := C.sqlite3_open(&char(path.str), &db)
|
||||
if code != 0 {
|
||||
|
@ -124,7 +124,7 @@ pub fn connect(path string) ?DB {
|
|||
// close Closes the DB.
|
||||
// TODO: For all functions, determine whether the connection is
|
||||
// closed first, and determine what to do if it is
|
||||
pub fn (mut db DB) close() ?bool {
|
||||
pub fn (mut db DB) close() !bool {
|
||||
code := C.sqlite3_close(db.conn)
|
||||
if code == 0 {
|
||||
db.is_open = false
|
||||
|
@ -217,7 +217,7 @@ pub fn (db &DB) exec(query string) ([]Row, int) {
|
|||
// Execute a query, handle error code
|
||||
// Return the first row from the resulting table
|
||||
[manualfree]
|
||||
pub fn (db &DB) exec_one(query string) ?Row {
|
||||
pub fn (db &DB) exec_one(query string) !Row {
|
||||
rows, code := db.exec(query)
|
||||
defer {
|
||||
unsafe { rows.free() }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue