Skip to content

Commit 01c7db6

Browse files
author
Dilovan Celik
committed
parse_select_into, outputclause and typos
1 parent 62b29ea commit 01c7db6

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

src/ast/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3830,7 +3830,7 @@ pub enum Statement {
38303830
/// Specifies the actions to perform when values match or do not match.
38313831
clauses: Vec<MergeClause>,
38323832
// Specifies the output to save changes in MSSQL
3833-
output: Option<Output>,
3833+
output: Option<OutputClause>,
38343834
},
38353835
/// ```sql
38363836
/// CACHE [ FLAG ] TABLE <table_name> [ OPTIONS('K1' = 'V1', 'K2' = V2) ] [ AS ] [ <query> ]
@@ -7908,7 +7908,7 @@ impl Display for MergeClause {
79087908
}
79097909
}
79107910

7911-
/// A Output in the end of a 'MERGE' Statement
7911+
/// A Output Clause in the end of a 'MERGE' Statement
79127912
///
79137913
/// Example:
79147914
/// OUTPUT $action, deleted.* INTO dbo.temp_products;
@@ -7921,9 +7921,9 @@ pub struct OutputClause {
79217921
pub into_table: SelectInto,
79227922
}
79237923

7924-
impl fmt::Display for Output {
7924+
impl fmt::Display for OutputClause {
79257925
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
7926-
let Output {
7926+
let OutputClause {
79277927
select_items,
79287928
into_table,
79297929
} = self;

src/parser/mod.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14493,7 +14493,6 @@ impl<'a> Parser<'a> {
1449314493
break;
1449414494
}
1449514495

14496-
1449714496
let mut clause_kind = MergeClauseKind::Matched;
1449814497
if self.parse_keyword(Keyword::NOT) {
1449914498
clause_kind = MergeClauseKind::NotMatched;
@@ -14586,26 +14585,31 @@ impl<'a> Parser<'a> {
1458614585
Ok(clauses)
1458714586
}
1458814587

14589-
fn parse_output(&mut self) -> Result<Output, ParserError> {
14588+
fn parse_output(&mut self) -> Result<OutputClause, ParserError> {
1459014589
self.expect_keyword_is(Keyword::OUTPUT)?;
1459114590
let select_items = self.parse_projection()?;
1459214591
self.expect_keyword_is(Keyword::INTO)?;
14592+
let into_table = self.parse_select_into()?;
14593+
14594+
Ok(OutputClause {
14595+
select_items,
14596+
into_table,
14597+
})
14598+
}
14599+
14600+
fn parse_select_into(&mut self) -> Result<SelectInto, ParserError> {
1459314601
let temporary = self
1459414602
.parse_one_of_keywords(&[Keyword::TEMP, Keyword::TEMPORARY])
1459514603
.is_some();
1459614604
let unlogged = self.parse_keyword(Keyword::UNLOGGED);
1459714605
let table = self.parse_keyword(Keyword::TABLE);
1459814606
let name = self.parse_object_name(false)?;
14599-
let into_table = SelectInto {
14607+
14608+
Ok(SelectInto {
1460014609
temporary,
1460114610
unlogged,
1460214611
table,
1460314612
name,
14604-
};
14605-
14606-
Ok(Output {
14607-
select_items,
14608-
into_table,
1460914613
})
1461014614
}
1461114615

tests/sqlparser_mssql.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1924,7 +1924,7 @@ fn ms_and_generic() -> TestedDialects {
19241924

19251925
#[test]
19261926
fn parse_mssql_merge_with_output() {
1927-
let stmt = "MERGE dso.products AS t\
1927+
let stmt = "MERGE dso.products AS t \
19281928
USING dsi.products AS \
19291929
s ON s.ProductID = t.ProductID \
19301930
WHEN MATCHED AND \

0 commit comments

Comments
 (0)