stringqb/src/drivers/mssql.rs

54 lines
1.2 KiB
Rust
Raw Normal View History

2019-04-05 20:46:07 -04:00
use super::*;
#[derive(Debug)]
pub struct MSSQL;
impl DatabaseDriver for MSSQL {
/// Get which characters are used to delimit identifiers
/// such as tables, and columns
fn _quotes(&self) -> (char, char) {
('[', ']')
}
fn query(&self, _query: &str) -> Result<(), ()> {
Ok(())
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_quote_identifier_bracket_quote() {
let driver = MSSQL {};
assert_eq!(
driver.quote_identifier("foo, bar, baz"),
"[foo],[bar],[baz]"
);
assert_eq!(
driver.quote_identifier("foo.bar, baz, fizz"),
"[foo].[bar],[baz],[fizz]"
);
}
#[test]
fn test_quote_identifiers_bracket_quote() {
let driver = MSSQL {};
assert_eq!(
driver.quote_identifiers(vec![
"\tfoo. bar".to_string(),
"baz".to_string(),
"fizz.\n\tbuzz.baz".to_string(),
]),
vec![
"[foo].[bar]".to_string(),
"[baz]".to_string(),
"[fizz].[buzz].[baz]".to_string(),
]
);
}
}