-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Escape single quotes on insert (#198)
- Loading branch information
Showing
9 changed files
with
114 additions
and
4 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,3 +26,27 @@ async fn insert_row() { | |
} | ||
} | ||
} | ||
|
||
#[tokio::test] | ||
async fn insert_row_with_single_quotes() { | ||
let connection_string = | ||
"jdbc:sqlserver://localhost;encrypt=true;username=sa;password=Njord_passw0rd;databaseName=NjordDatabase;"; | ||
let mut conn = mssql::open(connection_string).await; | ||
|
||
let table_row: User = User { | ||
id: AutoIncrementPrimaryKey::default(), | ||
username: "quote_user".to_string(), | ||
email: "[email protected]".to_string(), | ||
address: "Some Random 'Address' 1".to_string(), | ||
}; | ||
|
||
match conn { | ||
Ok(ref mut c) => { | ||
let result = mssql::insert(c, vec![table_row]).await; | ||
assert!(result.is_ok()); | ||
} | ||
Err(e) => { | ||
panic!("Failed to INSERT: {:?}", e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,3 +25,26 @@ fn insert_row() { | |
} | ||
} | ||
} | ||
|
||
#[test] | ||
fn insert_row_with_single_quotes() { | ||
let url = "mysql://njord_user:njord_password@localhost:3306/njord_db"; | ||
let mut conn = mysql::open(url); | ||
|
||
let table_row: User = User { | ||
id: AutoIncrementPrimaryKey::default(), | ||
username: "quote_user".to_string(), | ||
email: "[email protected]".to_string(), | ||
address: "Some Random 'Address' 1".to_string(), | ||
}; | ||
|
||
match conn { | ||
Ok(ref mut c) => { | ||
let result = mysql::insert(c, vec![table_row]); | ||
assert!(result.is_ok()); | ||
} | ||
Err(e) => { | ||
panic!("Failed to INSERT: {:?}", e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,3 +25,26 @@ fn insert_row() { | |
} | ||
} | ||
} | ||
|
||
#[test] | ||
fn insert_row_with_single_quotes() { | ||
let connection_string = "//localhost:1521/FREEPDB1"; | ||
let mut conn = oracle::open("njord_user", "njord_password", connection_string); | ||
|
||
let table_row: User = User { | ||
id: AutoIncrementPrimaryKey::default(), | ||
username: "quote_user".to_string(), | ||
email: "[email protected]".to_string(), | ||
address: "Some Random 'Address' 1".to_string(), | ||
}; | ||
|
||
match conn { | ||
Ok(ref mut c) => { | ||
let result = oracle::insert(c, vec![table_row]); | ||
assert!(result.is_ok()); | ||
} | ||
Err(e) => { | ||
panic!("Failed to INSERT: {:?}", e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,3 +68,27 @@ fn insert_with_sub_query() { | |
} | ||
} | ||
} | ||
|
||
#[test] | ||
fn insert_row_with_single_quotes() { | ||
let db_relative_path = "./db/insert.db"; | ||
let db_path = Path::new(&db_relative_path); | ||
let mut conn = sqlite::open(db_path); | ||
|
||
let table_row: User = User { | ||
id: AutoIncrementPrimaryKey::default(), | ||
username: "quote_user".to_string(), | ||
email: "[email protected]".to_string(), | ||
address: "Some Random 'Address' 1".to_string(), | ||
}; | ||
|
||
match conn { | ||
Ok(ref mut c) => { | ||
let result = sqlite::insert(c, vec![table_row]); | ||
assert!(result.is_ok()); | ||
} | ||
Err(e) => { | ||
panic!("Failed to INSERT: {:?}", e); | ||
} | ||
} | ||
} |