72 lines
1.5 KiB
Rust
72 lines
1.5 KiB
Rust
//! Database Driver for MSSQL
|
|
//!
|
|
//! Note:
|
|
//! **This driver will probably never be fully implemented**
|
|
//!
|
|
//! Contains database-specific query data
|
|
use super::*;
|
|
|
|
/// The struct implementing the `DatabaseDriver` trait
|
|
#[derive(Debug)]
|
|
pub struct MSSQL;
|
|
|
|
impl MSSQL {
|
|
/// Create a MSSQL Driver
|
|
pub fn new() -> Self {
|
|
MSSQL {}
|
|
}
|
|
}
|
|
|
|
impl DatabaseDriver for MSSQL {
|
|
/// Get which characters are used to delimit identifiers
|
|
/// such as tables, and columns
|
|
fn _quotes(&self) -> (char, char) {
|
|
('[', ']')
|
|
}
|
|
|
|
fn explain(&self, sql: &str) -> String {
|
|
sql.to_string()
|
|
}
|
|
|
|
fn random(&self) -> String {
|
|
String::from(" RANDOM")
|
|
}
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn test_quote_identifier_bracket_quote() {
|
|
let driver = MSSQL::new();
|
|
|
|
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::new();
|
|
|
|
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(),
|
|
]
|
|
);
|
|
}
|
|
}
|