MSSQL: Add support for functionality MERGE output clause (#1790)

This commit is contained in:
DilovanCelik 2025-04-05 18:37:28 +00:00 committed by GitHub
parent 3ed4ad9c66
commit 610096cad8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 109 additions and 16 deletions

View file

@ -1921,3 +1921,19 @@ fn ms() -> TestedDialects {
fn ms_and_generic() -> TestedDialects {
TestedDialects::new(vec![Box::new(MsSqlDialect {}), Box::new(GenericDialect {})])
}
#[test]
fn parse_mssql_merge_with_output() {
let stmt = "MERGE dso.products AS t \
USING dsi.products AS \
s ON s.ProductID = t.ProductID \
WHEN MATCHED AND \
NOT (t.ProductName = s.ProductName OR (ISNULL(t.ProductName, s.ProductName) IS NULL)) \
THEN UPDATE SET t.ProductName = s.ProductName \
WHEN NOT MATCHED BY TARGET \
THEN INSERT (ProductID, ProductName) \
VALUES (s.ProductID, s.ProductName) \
WHEN NOT MATCHED BY SOURCE THEN DELETE \
OUTPUT $action, deleted.ProductID INTO dsi.temp_products";
ms_and_generic().verified_stmt(stmt);
}