From 41e47cc0136c705a3335b1504d50ae8b22711b86 Mon Sep 17 00:00:00 2001 From: Ophir LOJKINE Date: Mon, 21 Aug 2023 19:21:45 +0200 Subject: [PATCH] add a test for mssql table name in square brackets (#952) --- tests/sqlparser_mssql.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/sqlparser_mssql.rs b/tests/sqlparser_mssql.rs index 56fbd576e..0bb2ba3de 100644 --- a/tests/sqlparser_mssql.rs +++ b/tests/sqlparser_mssql.rs @@ -324,6 +324,26 @@ fn parse_delimited_identifiers() { //TODO verified_stmt(r#"UPDATE foo SET "bar" = 5"#); } +#[test] +fn parse_table_name_in_square_brackets() { + let select = ms().verified_only_select(r#"SELECT [a column] FROM [a schema].[a table]"#); + if let TableFactor::Table { name, .. } = only(select.from).relation { + assert_eq!( + vec![ + Ident::with_quote('[', "a schema"), + Ident::with_quote('[', "a table") + ], + name.0 + ); + } else { + panic!("Expecting TableFactor::Table"); + } + assert_eq!( + &Expr::Identifier(Ident::with_quote('[', "a column")), + expr_from_projection(&select.projection[0]), + ); +} + #[test] fn parse_like() { fn chk(negated: bool) {