2019-04-03 20:58:22 -04:00
|
|
|
use super::*;
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub struct MySQL;
|
|
|
|
|
|
|
|
impl DatabaseDriver for MySQL {
|
2019-04-05 14:51:31 -04:00
|
|
|
/// Get which characters are used to delimit identifiers
|
|
|
|
/// such as tables, and columns
|
|
|
|
fn _quotes(&self) -> (char, char) {
|
2019-04-05 20:46:07 -04:00
|
|
|
('`', '`')
|
2019-04-03 20:58:22 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
fn query(&self, _query: &str) -> Result<(), ()> {
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|
2019-04-05 20:46:07 -04:00
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_quote_identifier_backtick_quote() {
|
|
|
|
let driver = MySQL {};
|
|
|
|
|
|
|
|
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_backtick_quote() {
|
|
|
|
let driver = MySQL {};
|
|
|
|
|
|
|
|
assert_eq!(
|
2019-04-05 22:37:06 -04:00
|
|
|
driver.quote_identifiers(vec!["\tfoo. bar", "baz", "fizz.\n\tbuzz.baz",]),
|
2019-04-05 20:46:07 -04:00
|
|
|
vec![
|
|
|
|
"`foo`.`bar`".to_string(),
|
|
|
|
"`baz`".to_string(),
|
|
|
|
"`fizz`.`buzz`.`baz`".to_string(),
|
|
|
|
]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|