-
Notifications
You must be signed in to change notification settings - Fork 760
Add xmlnamespace support mssql #2361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
bb95612
5d63c97
a903a0c
2dbfcba
7d0b184
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14108,12 +14108,31 @@ impl<'a> Parser<'a> { | |
| pub fn parse_query(&mut self) -> Result<Box<Query>, ParserError> { | ||
| let _guard = self.recursion_counter.try_decrease()?; | ||
| let with = if self.parse_keyword(Keyword::WITH) { | ||
| let with_token = self.get_current_token(); | ||
| Some(With { | ||
| with_token: with_token.clone().into(), | ||
| recursive: self.parse_keyword(Keyword::RECURSIVE), | ||
| cte_tables: self.parse_comma_separated(Parser::parse_cte)?, | ||
| }) | ||
| let with_token = self.get_current_token().clone(); | ||
| if self.dialect.supports_with_xmlnamespaces_clause() | ||
| && self.parse_keyword(Keyword::XMLNAMESPACES) | ||
| { | ||
| self.expect_token(&Token::LParen)?; | ||
| let _namespaces = | ||
| self.parse_comma_separated(Parser::parse_xml_namespace_definition)?; | ||
| self.expect_token(&Token::RParen)?; | ||
|
|
||
| if self.consume_token(&Token::Comma) { | ||
| Some(With { | ||
| with_token: with_token.clone().into(), | ||
| recursive: self.parse_keyword(Keyword::RECURSIVE), | ||
| cte_tables: self.parse_comma_separated(Parser::parse_cte)?, | ||
| }) | ||
| } else { | ||
| None | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the impl looks odd, is it parsing and dropping the content?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are correct, I missed the addition to AST fixed now |
||
| } | ||
| } else { | ||
| Some(With { | ||
| with_token: with_token.clone().into(), | ||
| recursive: self.parse_keyword(Keyword::RECURSIVE), | ||
| cte_tables: self.parse_comma_separated(Parser::parse_cte)?, | ||
| }) | ||
| } | ||
| } else { | ||
| None | ||
| }; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2923,3 +2923,25 @@ fn parse_mssql_money_constants() { | |
| expr_from_projection(only(&select.projection)), | ||
| ); | ||
| } | ||
|
|
||
| #[test] | ||
| fn parse_xmlnamespaces() { | ||
| let sql = r#"WITH XMLNAMESPACES ('urn:test' AS ns) | ||
| SELECT 1 AS [ns:Value] | ||
| FOR XML PATH('ns:Root');"#; | ||
|
|
||
| ms().parse_sql_statements(sql).unwrap(); | ||
|
|
||
| } | ||
|
|
||
| #[test] | ||
| fn parse_xmlnamespaces_with_cte() { | ||
| let sql = r#" | ||
| WITH XMLNAMESPACES ('urn:example' AS ns), t AS ( | ||
| SELECT 1 AS id | ||
| ) | ||
| SELECT id FROM t | ||
| "#; | ||
|
|
||
| ms().parse_sql_statements(sql).unwrap(); | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's merge these and have them use verified_stmt |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we include a link to the documentation of this syntax?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@iffyio Added documentation link