Skip to content

Commit 2c6654e

Browse files
authored
Merge pull request #9 from CoLearn-Dev/base64_serializer
Rename affected_rows and remove magic string, bump version
2 parents e794551 + 41ad527 commit 2c6654e

File tree

6 files changed

+14
-14
lines changed

6 files changed

+14
-14
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rdbc2"
3-
version = "0.2.0"
3+
version = "0.2.1"
44
edition = "2021"
55
authors = ["nociza"]
66
description = "Rust Database Connectivity Interface"

src/dbc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ impl Row {
108108
#[derive(Serialize, Deserialize, Debug)]
109109
pub struct QueryResult {
110110
pub rows: Vec<Row>,
111-
pub affected_rows: usize,
111+
pub affected_row_count: usize,
112112
}
113113

114114
#[derive(Serialize, Deserialize, Clone, Debug)]

src/dbc/mysql.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl dbc::Connection for MySQLConnection {
5858
}
5959
Ok(dbc::QueryResult {
6060
rows,
61-
affected_rows,
61+
affected_row_count: affected_rows,
6262
})
6363
}
6464
Err(err) => {
@@ -99,7 +99,7 @@ impl dbc::Connection for MySQLConnection {
9999
}
100100
return Ok(dbc::QueryResult {
101101
rows,
102-
affected_rows,
102+
affected_row_count: affected_rows,
103103
});
104104
}
105105
Err(dbc::Error::from(err))

src/dbc/sqlite.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl dbc::Connection for SQLiteConnection {
4141
let affected_rows = statement.execute([])?;
4242
return Ok(dbc::QueryResult {
4343
rows: Vec::new(),
44-
affected_rows,
44+
affected_row_count: affected_rows,
4545
});
4646
}
4747

@@ -61,7 +61,7 @@ impl dbc::Connection for SQLiteConnection {
6161
}
6262
Ok(dbc::QueryResult {
6363
rows,
64-
affected_rows: 0_usize,
64+
affected_row_count: 0_usize,
6565
})
6666
}
6767
}

tests/common.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub(crate) async fn test_simple_query(mut database: dbc::Database) -> Result<(),
3232
// Update the name of the first row to "updated"
3333
let update_query = "UPDATE test_table SET name = ? WHERE id = ?";
3434
let result = database.execute_query_with_params(update_query, &["updated", "1"])?;
35-
assert_eq!(result.affected_rows, 1);
35+
assert_eq!(result.affected_row_count, 1);
3636

3737
// Select the first row from test_table where the name is "updated"
3838
let select_query = "SELECT * FROM test_table WHERE name = ?";
@@ -55,9 +55,9 @@ pub(crate) async fn test_query_with_params(mut database: dbc::Database) -> Resul
5555
// Insert two rows into test_table
5656
let insert_query = "INSERT INTO test_table (name) VALUES (?)";
5757
let result = database.execute_query_with_params(insert_query, &["test1"])?;
58-
assert_eq!(result.affected_rows, 1);
58+
assert_eq!(result.affected_row_count, 1);
5959
let result = database.execute_query_with_params(insert_query, &["test2"])?;
60-
assert_eq!(result.affected_rows, 1);
60+
assert_eq!(result.affected_row_count, 1);
6161

6262
// Select all rows from test_table
6363
let select_query = "SELECT * FROM test_table";
@@ -79,7 +79,7 @@ pub(crate) async fn test_query_with_params(mut database: dbc::Database) -> Resul
7979
// Update the name of the first row to "updated"
8080
let update_query = "UPDATE test_table SET name = ? WHERE id = ?";
8181
let result = database.execute_query_with_params(update_query, &["updated", "1"])?;
82-
assert_eq!(result.affected_rows, 1);
82+
assert_eq!(result.affected_row_count, 1);
8383

8484
// Select the first row from test_table where the name is "updated"
8585
let select_query = "SELECT * FROM test_table WHERE name = ?";
@@ -104,14 +104,14 @@ pub(crate) async fn test_query_with_params_and_serialize(
104104
// Insert two rows into test_table
105105
let insert_query = "INSERT INTO test_table (name) VALUES (?)";
106106
let result = database.execute_query_with_params(insert_query, &["test1"])?;
107-
assert_eq!(result.affected_rows, 1);
107+
assert_eq!(result.affected_row_count, 1);
108108
let result = database.execute_query_with_params(insert_query, &["test2"])?;
109-
assert_eq!(result.affected_rows, 1);
109+
assert_eq!(result.affected_row_count, 1);
110110

111111
// Update the name of the first row to "updated"
112112
let update_query = "UPDATE test_table SET name = ? WHERE id = ?";
113113
let result = database.execute_query_with_params(update_query, &["updated", "1"])?;
114-
assert_eq!(result.affected_rows, 1);
114+
assert_eq!(result.affected_row_count, 1);
115115

116116
// Select the first row from test_table where the name is "updated"
117117
let select_query = "SELECT * FROM test_table WHERE id = ?";

tests/mysql_test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ fn _get_mysql_connection_url() -> String {
88
if std::env::var("MYSQL_DATABASE_URL").is_ok() {
99
std::env::var("MYSQL_DATABASE_URL").unwrap()
1010
} else {
11-
"mysql://localhost:3306/?user=nociza&password=password".to_owned()
11+
panic!("Please set the environment variable MYSQL_DATABASE_URL to a valid MySQL connection string.");
1212
}
1313
}
1414

0 commit comments

Comments
 (0)