diff --git a/src/token.rs b/src/token.rs index 44ddf62b..1d0ee971 100644 --- a/src/token.rs +++ b/src/token.rs @@ -454,7 +454,7 @@ mod tests { #[test] fn test_9() { - let string = r#"[ab] "#; + let string = r"[ab] "; let tokenizer = Tokenizer::new(string); let tokens: Vec = tokenizer.iter().collect(); assert_eq!( @@ -491,7 +491,7 @@ mod tests { #[test] fn test_11() { - let string = r#" `a``b` "#; + let string = r" `a``b` "; let tokenizer = Tokenizer::new(string); let tokens: Vec = tokenizer.iter().collect(); assert_eq!( @@ -510,7 +510,7 @@ mod tests { #[test] fn test_12() { - let string = r#" 'a''b' "#; + let string = r" 'a''b' "; let tokenizer = Tokenizer::new(string); let tokens: Vec = tokenizer.iter().collect(); assert_eq!( @@ -529,7 +529,7 @@ mod tests { #[test] fn test_13() { - let string = r#"(?)"#; + let string = r"(?)"; let tokenizer = Tokenizer::new(string); let tokens: Vec = tokenizer.iter().collect(); assert_eq!( @@ -548,7 +548,7 @@ mod tests { #[test] fn test_14() { - let string = r#"($1 = $2)"#; + let string = r"($1 = $2)"; let tokenizer = Tokenizer::new(string); let tokens: Vec = tokenizer.iter().collect(); assert_eq!( diff --git a/src/types.rs b/src/types.rs index a58c751b..e12919bb 100644 --- a/src/types.rs +++ b/src/types.rs @@ -623,10 +623,7 @@ mod tests { .to_owned(); #[cfg(feature = "backend-mysql")] - assert_eq!( - query.to_string(MysqlQueryBuilder), - r#"SELECT `hello-World_`"# - ); + assert_eq!(query.to_string(MysqlQueryBuilder), r"SELECT `hello-World_`"); #[cfg(feature = "backend-postgres")] assert_eq!( query.to_string(PostgresQueryBuilder), @@ -644,7 +641,7 @@ mod tests { let query = Query::select().column(Alias::new("hel`lo")).to_owned(); #[cfg(feature = "backend-mysql")] - assert_eq!(query.to_string(MysqlQueryBuilder), r#"SELECT `hel``lo`"#); + assert_eq!(query.to_string(MysqlQueryBuilder), r"SELECT `hel``lo`"); #[cfg(feature = "backend-sqlite")] assert_eq!(query.to_string(SqliteQueryBuilder), r#"SELECT "hel`lo""#); @@ -659,7 +656,7 @@ mod tests { let query = Query::select().column(Alias::new("hel``lo")).to_owned(); #[cfg(feature = "backend-mysql")] - assert_eq!(query.to_string(MysqlQueryBuilder), r#"SELECT `hel````lo`"#); + assert_eq!(query.to_string(MysqlQueryBuilder), r"SELECT `hel````lo`"); #[cfg(feature = "backend-sqlite")] assert_eq!(query.to_string(SqliteQueryBuilder), r#"SELECT "hel``lo""#); diff --git a/tests/mysql/query.rs b/tests/mysql/query.rs index a9e46525..dc33d876 100644 --- a/tests/mysql/query.rs +++ b/tests/mysql/query.rs @@ -518,7 +518,7 @@ fn select_35() { assert_eq!( statement, - r#"SELECT `id` FROM `glyph` WHERE `aspect` IS NULL"# + r"SELECT `id` FROM `glyph` WHERE `aspect` IS NULL" ); assert_eq!(values.0, vec![]); } @@ -533,7 +533,7 @@ fn select_36() { assert_eq!( statement, - r#"SELECT `id` FROM `glyph` WHERE `aspect` IS NULL"# + r"SELECT `id` FROM `glyph` WHERE `aspect` IS NULL" ); assert_eq!(values.0, vec![]); } @@ -546,7 +546,7 @@ fn select_37() { .cond_where(Cond::any().add(Cond::all()).add(Cond::any())) .build(MysqlQueryBuilder); - assert_eq!(statement, r#"SELECT `id` FROM `glyph` WHERE TRUE OR FALSE"#); + assert_eq!(statement, r"SELECT `id` FROM `glyph` WHERE TRUE OR FALSE"); assert_eq!(values.0, vec![]); } @@ -565,7 +565,7 @@ fn select_37a() { assert_eq!( statement, - r#"SELECT `id` FROM `glyph` WHERE NOT ((NOT TRUE) AND (NOT FALSE))"# + r"SELECT `id` FROM `glyph` WHERE NOT ((NOT TRUE) AND (NOT FALSE))" ); assert_eq!(values.0, vec![]); } @@ -584,7 +584,7 @@ fn select_38() { assert_eq!( statement, - r#"SELECT `id` FROM `glyph` WHERE `aspect` IS NULL OR `aspect` IS NOT NULL"# + r"SELECT `id` FROM `glyph` WHERE `aspect` IS NULL OR `aspect` IS NOT NULL" ); assert_eq!(values.0, vec![]); } @@ -603,7 +603,7 @@ fn select_39() { assert_eq!( statement, - r#"SELECT `id` FROM `glyph` WHERE `aspect` IS NULL AND `aspect` IS NOT NULL"# + r"SELECT `id` FROM `glyph` WHERE `aspect` IS NULL AND `aspect` IS NOT NULL" ); assert_eq!(values.0, vec![]); } @@ -624,7 +624,7 @@ fn select_40() { assert_eq!( statement, - r#"SELECT `id` FROM `glyph` WHERE `aspect` IS NULL OR (`aspect` IS NOT NULL AND `aspect` < 8)"# + r"SELECT `id` FROM `glyph` WHERE `aspect` IS NULL OR (`aspect` IS NOT NULL AND `aspect` < 8)" ); } @@ -656,7 +656,7 @@ fn select_42() { assert_eq!( statement, - r#"SELECT `id` FROM `glyph` WHERE `aspect` < 8 AND `aspect` IS NOT NULL"# + r"SELECT `id` FROM `glyph` WHERE `aspect` < 8 AND `aspect` IS NOT NULL" ); } @@ -685,7 +685,7 @@ fn select_44() { assert_eq!( statement, - r#"SELECT `id` FROM `glyph` WHERE NOT `aspect` < 8"# + r"SELECT `id` FROM `glyph` WHERE NOT `aspect` < 8" ); } @@ -704,7 +704,7 @@ fn select_45() { assert_eq!( statement, - r#"SELECT `id` FROM `glyph` WHERE NOT (`aspect` < 8 OR `aspect` IS NOT NULL)"# + r"SELECT `id` FROM `glyph` WHERE NOT (`aspect` < 8 OR `aspect` IS NOT NULL)" ); } @@ -722,7 +722,7 @@ fn select_46() { assert_eq!( statement, - r#"SELECT `id` FROM `glyph` WHERE NOT `aspect` < 8"# + r"SELECT `id` FROM `glyph` WHERE NOT `aspect` < 8" ); } @@ -741,7 +741,7 @@ fn select_47() { assert_eq!( statement, - r#"SELECT `id` FROM `glyph` WHERE NOT (`aspect` < 8 AND `aspect` IS NOT NULL)"# + r"SELECT `id` FROM `glyph` WHERE NOT (`aspect` < 8 AND `aspect` IS NOT NULL)" ); } @@ -760,7 +760,7 @@ fn select_48() { assert_eq!( statement, - r#"SELECT `id` FROM `glyph` WHERE (`aspect`, 100) < (8, 100)"# + r"SELECT `id` FROM `glyph` WHERE (`aspect`, 100) < (8, 100)" ); } @@ -782,7 +782,7 @@ fn select_48a() { assert_eq!( statement, - r#"SELECT `id` FROM `glyph` WHERE (`aspect`, '100') IN ((8, '100'))"# + r"SELECT `id` FROM `glyph` WHERE (`aspect`, '100') IN ((8, '100'))" ); } @@ -793,7 +793,7 @@ fn select_49() { .from(Char::Table) .to_string(MysqlQueryBuilder); - assert_eq!(statement, r#"SELECT * FROM `character`"#); + assert_eq!(statement, r"SELECT * FROM `character`"); } #[test] @@ -810,7 +810,7 @@ fn select_50() { assert_eq!( statement, - r#"SELECT `character`.*, `font`.`name` FROM `character` INNER JOIN `font` ON `character`.`font_id` = `font`.`id`"# + r"SELECT `character`.*, `font`.`name` FROM `character` INNER JOIN `font` ON `character`.`font_id` = `font`.`id`" ) } @@ -829,13 +829,13 @@ fn select_51() { ) .to_string(MysqlQueryBuilder), [ - r#"SELECT `aspect`"#, - r#"FROM `glyph`"#, - r#"WHERE IFNULL(`aspect`, 0) > 2"#, - r#"ORDER BY `image` IS NULL DESC,"#, - r#"`image` DESC,"#, - r#"`glyph`.`aspect` IS NULL ASC,"#, - r#"`glyph`.`aspect` ASC"#, + r"SELECT `aspect`", + r"FROM `glyph`", + r"WHERE IFNULL(`aspect`, 0) > 2", + r"ORDER BY `image` IS NULL DESC,", + r"`image` DESC,", + r"`glyph`.`aspect` IS NULL ASC,", + r"`glyph`.`aspect` ASC", ] .join(" ") ); @@ -854,13 +854,13 @@ fn select_52() { ]) .to_string(MysqlQueryBuilder), [ - r#"SELECT `aspect`"#, - r#"FROM `glyph`"#, - r#"WHERE IFNULL(`aspect`, 0) > 2"#, - r#"ORDER BY `id` IS NULL DESC,"#, - r#"`id` ASC,"#, - r#"`aspect` IS NULL ASC,"#, - r#"`aspect` DESC"#, + r"SELECT `aspect`", + r"FROM `glyph`", + r"WHERE IFNULL(`aspect`, 0) > 2", + r"ORDER BY `id` IS NULL DESC,", + r"`id` ASC,", + r"`aspect` IS NULL ASC,", + r"`aspect` DESC", ] .join(" ") ); @@ -883,13 +883,13 @@ fn select_53() { ]) .to_string(MysqlQueryBuilder), [ - r#"SELECT `aspect`"#, - r#"FROM `glyph`"#, - r#"WHERE IFNULL(`aspect`, 0) > 2"#, - r#"ORDER BY `glyph`.`id` IS NULL DESC,"#, - r#"`glyph`.`id` ASC,"#, - r#"`glyph`.`aspect` IS NULL ASC,"#, - r#"`glyph`.`aspect` DESC"#, + r"SELECT `aspect`", + r"FROM `glyph`", + r"WHERE IFNULL(`aspect`, 0) > 2", + r"ORDER BY `glyph`.`id` IS NULL DESC,", + r"`glyph`.`id` ASC,", + r"`glyph`.`aspect` IS NULL ASC,", + r"`glyph`.`aspect` DESC", ] .join(" ") ); @@ -906,7 +906,7 @@ fn select_54() { assert_eq!( statement, - r#"SELECT * FROM `character`, `font` WHERE `font`.`id` = `character`.`font_id`"# + r"SELECT * FROM `character`, `font` WHERE `font`.`id` = `character`.`font_id`" ); } @@ -924,16 +924,16 @@ fn select_55() { .order_by((Glyph::Table, Glyph::Aspect), Order::Asc) .to_string(MysqlQueryBuilder), [ - r#"SELECT `aspect`"#, - r#"FROM `glyph`"#, - r#"WHERE IFNULL(`aspect`, 0) > 2"#, - r#"ORDER BY CASE"#, - r#"WHEN `id`=4 THEN 0"#, - r#"WHEN `id`=5 THEN 1"#, - r#"WHEN `id`=1 THEN 2"#, - r#"WHEN `id`=3 THEN 3"#, - r#"ELSE 4 END,"#, - r#"`glyph`.`aspect` ASC"#, + r"SELECT `aspect`", + r"FROM `glyph`", + r"WHERE IFNULL(`aspect`, 0) > 2", + r"ORDER BY CASE", + r"WHEN `id`=4 THEN 0", + r"WHEN `id`=5 THEN 1", + r"WHEN `id`=1 THEN 2", + r"WHEN `id`=3 THEN 3", + r"ELSE 4 END,", + r"`glyph`.`aspect` ASC", ] .join(" ") ); @@ -953,15 +953,15 @@ fn select_56() { ) .to_string(MysqlQueryBuilder), [ - r#"SELECT `aspect`"#, - r#"FROM `glyph`"#, - r#"WHERE IFNULL(`aspect`, 0) > 2"#, - r#"ORDER BY `glyph`.`aspect` ASC,"#, - r#"CASE WHEN `id`=4 THEN 0"#, - r#"WHEN `id`=5 THEN 1"#, - r#"WHEN `id`=1 THEN 2"#, - r#"WHEN `id`=3 THEN 3"#, - r#"ELSE 4 END"#, + r"SELECT `aspect`", + r"FROM `glyph`", + r"WHERE IFNULL(`aspect`, 0) > 2", + r"ORDER BY `glyph`.`aspect` ASC,", + r"CASE WHEN `id`=4 THEN 0", + r"WHEN `id`=5 THEN 1", + r"WHEN `id`=1 THEN 2", + r"WHEN `id`=3 THEN 3", + r"ELSE 4 END", ] .join(" ") ); @@ -982,7 +982,7 @@ fn select_57() { assert_eq!( query.to_string(MysqlQueryBuilder), - r#"SELECT (CASE WHEN (`glyph`.`aspect` > 0) THEN 'positive' WHEN (`glyph`.`aspect` < 0) THEN 'negative' ELSE 'zero' END) AS `polarity` FROM `glyph`"# + r"SELECT (CASE WHEN (`glyph`.`aspect` > 0) THEN 'positive' WHEN (`glyph`.`aspect` < 0) THEN 'negative' ELSE 'zero' END) AS `polarity` FROM `glyph`" ); } @@ -1049,13 +1049,13 @@ fn select_61() { .offset(100) .to_string(MysqlQueryBuilder), [ - r#"SELECT `character`, `size_w`, `size_h`"#, - r#"FROM `character`"#, - r#"IGNORE INDEX FOR JOIN (`IDX_123456`)"#, - r#"USE INDEX FOR GROUP BY (`IDX_789ABC`)"#, - r#"FORCE INDEX FOR ORDER BY (`IDX_DEFGHI`)"#, - r#"LIMIT 10"#, - r#"OFFSET 100"#, + r"SELECT `character`, `size_w`, `size_h`", + r"FROM `character`", + r"IGNORE INDEX FOR JOIN (`IDX_123456`)", + r"USE INDEX FOR GROUP BY (`IDX_789ABC`)", + r"FORCE INDEX FOR ORDER BY (`IDX_DEFGHI`)", + r"LIMIT 10", + r"OFFSET 100", ] .join(" ") ); @@ -1193,7 +1193,7 @@ fn insert_from_select() { .unwrap() .to_owned() .to_string(MysqlQueryBuilder), - r#"INSERT INTO `glyph` (`aspect`, `image`) SELECT `aspect`, `image` FROM `glyph` WHERE `image` LIKE '%'"# + r"INSERT INTO `glyph` (`aspect`, `image`) SELECT `aspect`, `image` FROM `glyph` WHERE `image` LIKE '%'" ); } @@ -1215,9 +1215,9 @@ fn insert_on_conflict_0() { ) .to_string(MysqlQueryBuilder), [ - r#"INSERT INTO `glyph` (`aspect`, `image`)"#, - r#"VALUES ('04108048005887010020060000204E0180400400', 3.1415)"#, - r#"ON DUPLICATE KEY UPDATE `aspect` = VALUES(`aspect`), `image` = VALUES(`image`)"#, + r"INSERT INTO `glyph` (`aspect`, `image`)", + r"VALUES ('04108048005887010020060000204E0180400400', 3.1415)", + r"ON DUPLICATE KEY UPDATE `aspect` = VALUES(`aspect`), `image` = VALUES(`image`)", ] .join(" ") ); @@ -1241,9 +1241,9 @@ fn insert_on_conflict_1() { ) .to_string(MysqlQueryBuilder), [ - r#"INSERT INTO `glyph` (`aspect`, `image`)"#, - r#"VALUES ('04108048005887010020060000204E0180400400', 3.1415)"#, - r#"ON DUPLICATE KEY UPDATE `aspect` = VALUES(`aspect`)"#, + r"INSERT INTO `glyph` (`aspect`, `image`)", + r"VALUES ('04108048005887010020060000204E0180400400', 3.1415)", + r"ON DUPLICATE KEY UPDATE `aspect` = VALUES(`aspect`)", ] .join(" ") ); @@ -1267,9 +1267,9 @@ fn insert_on_conflict_2() { ) .to_string(MysqlQueryBuilder), [ - r#"INSERT INTO `glyph` (`aspect`, `image`)"#, - r#"VALUES ('04108048005887010020060000204E0180400400', 3.1415)"#, - r#"ON DUPLICATE KEY UPDATE `aspect` = VALUES(`aspect`), `image` = VALUES(`image`)"#, + r"INSERT INTO `glyph` (`aspect`, `image`)", + r"VALUES ('04108048005887010020060000204E0180400400', 3.1415)", + r"ON DUPLICATE KEY UPDATE `aspect` = VALUES(`aspect`), `image` = VALUES(`image`)", ] .join(" ") ); @@ -1296,9 +1296,9 @@ fn insert_on_conflict_3() { ) .to_string(MysqlQueryBuilder), [ - r#"INSERT INTO `glyph` (`aspect`, `image`)"#, - r#"VALUES ('04108048005887010020060000204E0180400400', 3.1415)"#, - r#"ON DUPLICATE KEY UPDATE `aspect` = '04108048005887010020060000204E0180400400', `image` = 3.1415"#, + r"INSERT INTO `glyph` (`aspect`, `image`)", + r"VALUES ('04108048005887010020060000204E0180400400', 3.1415)", + r"ON DUPLICATE KEY UPDATE `aspect` = '04108048005887010020060000204E0180400400', `image` = 3.1415", ] .join(" ") ); @@ -1322,9 +1322,9 @@ fn insert_on_conflict_4() { ) .to_string(MysqlQueryBuilder), [ - r#"INSERT INTO `glyph` (`aspect`, `image`)"#, - r#"VALUES ('04108048005887010020060000204E0180400400', 3.1415)"#, - r#"ON DUPLICATE KEY UPDATE `image` = 1 + 2"#, + r"INSERT INTO `glyph` (`aspect`, `image`)", + r"VALUES ('04108048005887010020060000204E0180400400', 3.1415)", + r"ON DUPLICATE KEY UPDATE `image` = 1 + 2", ] .join(" ") ); @@ -1349,9 +1349,9 @@ fn insert_on_conflict_5() { ) .to_string(MysqlQueryBuilder), [ - r#"INSERT INTO `glyph` (`aspect`, `image`)"#, - r#"VALUES ('04108048005887010020060000204E0180400400', 3.1415)"#, - r#"ON DUPLICATE KEY UPDATE `aspect` = '04108048005887010020060000204E0180400400', `image` = VALUES(`image`)"#, + r"INSERT INTO `glyph` (`aspect`, `image`)", + r"VALUES ('04108048005887010020060000204E0180400400', 3.1415)", + r"ON DUPLICATE KEY UPDATE `aspect` = '04108048005887010020060000204E0180400400', `image` = VALUES(`image`)", ] .join(" ") ); @@ -1376,9 +1376,9 @@ fn insert_on_conflict_6() { ) .to_string(MysqlQueryBuilder), [ - r#"INSERT INTO `glyph` (`aspect`, `image`)"#, - r#"VALUES ('04108048005887010020060000204E0180400400', 3.1415)"#, - r#"ON DUPLICATE KEY UPDATE `aspect` = VALUES(`aspect`), `image` = 1 + 2"#, + r"INSERT INTO `glyph` (`aspect`, `image`)", + r"VALUES ('04108048005887010020060000204E0180400400', 3.1415)", + r"ON DUPLICATE KEY UPDATE `aspect` = VALUES(`aspect`), `image` = 1 + 2", ] .join(" ") ); @@ -1399,9 +1399,9 @@ fn insert_on_conflict_do_nothing_on() { ) .to_string(MysqlQueryBuilder), [ - r#"INSERT INTO `glyph` (`aspect`, `image`)"#, - r#"VALUES ('abcd', 3.1415)"#, - r#"ON DUPLICATE KEY UPDATE `id` = `id`"#, + r"INSERT INTO `glyph` (`aspect`, `image`)", + r"VALUES ('abcd', 3.1415)", + r"ON DUPLICATE KEY UPDATE `id` = `id`", ] .join(" ") ); diff --git a/tests/mysql/table.rs b/tests/mysql/table.rs index 0d3a7d09..5f71f4e7 100644 --- a/tests/mysql/table.rs +++ b/tests/mysql/table.rs @@ -359,7 +359,7 @@ fn create_with_check_constraint() { .check(Expr::col(Glyph::Id).lt(20)) .check(Expr::col(Glyph::Id).ne(15)) .to_string(MysqlQueryBuilder), - r#"CREATE TABLE `glyph` ( `id` int NOT NULL CHECK (`id` > 10), CHECK (`id` < 20), CHECK (`id` <> 15) )"#, + r"CREATE TABLE `glyph` ( `id` int NOT NULL CHECK (`id` > 10), CHECK (`id` < 20), CHECK (`id` <> 15) )", ); } @@ -376,6 +376,6 @@ fn alter_with_check_constraint() { .check(Expr::col(Glyph::Aspect).gt(100)) ) .to_string(MysqlQueryBuilder), - r#"ALTER TABLE `glyph` ADD COLUMN `aspect` int NOT NULL DEFAULT 101 CHECK (`aspect` > 100)"#, + r"ALTER TABLE `glyph` ADD COLUMN `aspect` int NOT NULL DEFAULT 101 CHECK (`aspect` > 100)", ); } diff --git a/tests/sqlite/query.rs b/tests/sqlite/query.rs index 9a9c8fcf..57f0a774 100644 --- a/tests/sqlite/query.rs +++ b/tests/sqlite/query.rs @@ -434,7 +434,7 @@ fn select_31() { Query::select() .expr((1..10_i32).fold(Expr::value(0), |expr, i| { expr.add(i) })) .to_string(SqliteQueryBuilder), - r#"SELECT 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9"# + r"SELECT 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9" ); }