From 5122252ee3b25bf88caca1c33959ca73cdf184ea Mon Sep 17 00:00:00 2001 From: MayerTim Date: Wed, 10 Jun 2026 23:01:37 +0200 Subject: [PATCH] test(formatter): add exception handler corpus guards --- test/corpus/watcom/exception-handler.expected.sql | 10 ++++++++++ test/corpus/watcom/exception-handler.input.sql | 8 ++++++++ .../exception-resume-and-declarations.expected.sql | 6 ++++++ .../watcom/exception-resume-and-declarations.input.sql | 6 ++++++ 4 files changed, 30 insertions(+) create mode 100644 test/corpus/watcom/exception-handler.expected.sql create mode 100644 test/corpus/watcom/exception-handler.input.sql create mode 100644 test/corpus/watcom/exception-resume-and-declarations.expected.sql create mode 100644 test/corpus/watcom/exception-resume-and-declarations.input.sql diff --git a/test/corpus/watcom/exception-handler.expected.sql b/test/corpus/watcom/exception-handler.expected.sql new file mode 100644 index 0000000..4fa51e1 --- /dev/null +++ b/test/corpus/watcom/exception-handler.expected.sql @@ -0,0 +1,10 @@ +CREATE PROCEDURE dbo.handle_import_errors() +BEGIN + SET status_code = 1; +EXCEPTION + WHEN OTHERS THEN + BEGIN + SET status_code = 0; + SELECT sqlcode, SQLSTATE; + END +END; diff --git a/test/corpus/watcom/exception-handler.input.sql b/test/corpus/watcom/exception-handler.input.sql new file mode 100644 index 0000000..86bdae4 --- /dev/null +++ b/test/corpus/watcom/exception-handler.input.sql @@ -0,0 +1,8 @@ +create procedure dbo.handle_import_errors() +begin +set status_code = 1; +exception when others then begin +set status_code = 0; +select sqlcode, sqlstate; +end +end; diff --git a/test/corpus/watcom/exception-resume-and-declarations.expected.sql b/test/corpus/watcom/exception-resume-and-declarations.expected.sql new file mode 100644 index 0000000..b88e1d0 --- /dev/null +++ b/test/corpus/watcom/exception-resume-and-declarations.expected.sql @@ -0,0 +1,6 @@ +CREATE PROCEDURE dbo.exception_resume_guard() +BEGIN + ON EXCEPTION RESUME + DECLARE "validation_error" EXCEPTION FOR SQLSTATE VALUE '75000'; + SELECT 'exception when others then begin' AS note -- exception when others then begin +END; diff --git a/test/corpus/watcom/exception-resume-and-declarations.input.sql b/test/corpus/watcom/exception-resume-and-declarations.input.sql new file mode 100644 index 0000000..01279d0 --- /dev/null +++ b/test/corpus/watcom/exception-resume-and-declarations.input.sql @@ -0,0 +1,6 @@ +create procedure dbo.exception_resume_guard() +begin +on exception resume +declare "validation_error" exception for sqlstate value '75000'; +select 'exception when others then begin' as note -- exception when others then begin +end;