Skip to content

Commit 3093506

Browse files
committed
Add support for constraints in table valued function definitions
1 parent f1215e6 commit 3093506

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

src/parser/mod.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9870,13 +9870,7 @@ impl<'a> Parser<'a> {
98709870
}
98719871

98729872
fn parse_returns_table_column(&mut self) -> Result<ColumnDef, ParserError> {
9873-
let name = self.parse_identifier()?;
9874-
let data_type = self.parse_data_type()?;
9875-
Ok(ColumnDef {
9876-
name,
9877-
data_type,
9878-
options: Vec::new(), // No constraints expected here
9879-
})
9873+
self.parse_column_def()
98809874
}
98819875

98829876
fn parse_returns_table_columns(&mut self) -> Result<Vec<ColumnDef>, ParserError> {

tests/sqlparser_mssql.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,17 @@ fn parse_create_function() {
327327
&create_multi_statement_table_value_function_without_as,
328328
create_multi_statement_table_value_function,
329329
);
330+
331+
let create_multi_statement_table_value_function_with_constraints = "\
332+
CREATE FUNCTION some_multi_statement_tvf(@foo INT, @bar VARCHAR(256)) \
333+
RETURNS @t TABLE (col_1 INT NOT NULL) \
334+
AS \
335+
BEGIN \
336+
INSERT INTO @t SELECT 1; \
337+
RETURN @t; \
338+
END\
339+
";
340+
let _ = ms().verified_stmt(create_multi_statement_table_value_function_with_constraints);
330341
}
331342

332343
#[test]

0 commit comments

Comments
 (0)