Skip to content

Commit

Permalink
[query] Return Result<> from exec #47 (#48)
Browse files Browse the repository at this point in the history
* Update transaction_test.rs

* Update db_test.rs

* Update transaction.rs

* Update db.rs
  • Loading branch information
michaelvlach authored Aug 20, 2022
1 parent 54c4de2 commit a90b913
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/db.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use crate::{Query, QueryResult, Transaction};
use crate::{Query, QueryError, QueryResult, Transaction};

#[derive(Default)]
pub struct Db {}

impl Db {
pub fn exec(&self, _query: Query) -> QueryResult {
QueryResult::default()
pub fn exec(&self, _query: Query) -> Result<QueryResult, QueryError> {
Ok(QueryResult::default())
}

pub fn transaction(&self) -> Transaction {
Expand Down
4 changes: 2 additions & 2 deletions src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ impl Transaction {
Ok(QueryResult::default())
}

pub fn exec(&self, _query: Query) -> QueryResult {
QueryResult::default()
pub fn exec(&self, _query: Query) -> Result<QueryResult, QueryError> {
Ok(QueryResult::default())
}

pub fn transaction(&self) -> Transaction {
Expand Down
2 changes: 1 addition & 1 deletion tests/db_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ fn db_is_public_type() {
fn exec_takes_query_returns_query_result() {
let db = agdb::Db::default();
let query = agdb::Query::default();
let _result: agdb::QueryResult = db.exec(query);
let _result: Result<agdb::QueryResult, agdb::QueryError> = db.exec(query);
}
2 changes: 1 addition & 1 deletion tests/transaction_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fn exec_takes_query_returns_query_result() {
let db = agdb::Db::default();
let query = agdb::Query::default();
let transaction = db.transaction();
let _result: agdb::QueryResult = transaction.exec(query);
let _result: Result<agdb::QueryResult, agdb::QueryError> = transaction.exec(query);
}

#[test]
Expand Down

0 comments on commit a90b913

Please sign in to comment.