Add DROP TRIGGER support for SQL Server (#1813)

This commit is contained in:
Andrew Harper 2025-04-15 01:50:50 -04:00 committed by GitHub
parent 896c088153
commit 6566c47593
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 1 deletions

View file

@ -5177,7 +5177,7 @@ impl<'a> Parser<'a> {
/// DROP TRIGGER [ IF EXISTS ] name ON table_name [ CASCADE | RESTRICT ]
/// ```
pub fn parse_drop_trigger(&mut self) -> Result<Statement, ParserError> {
if !dialect_of!(self is PostgreSqlDialect | GenericDialect | MySqlDialect) {
if !dialect_of!(self is PostgreSqlDialect | GenericDialect | MySqlDialect | MsSqlDialect) {
self.prev_token();
return self.expected("an object type after DROP", self.peek_token());
}

View file

@ -2038,3 +2038,18 @@ fn parse_mssql_merge_with_output() {
OUTPUT $action, deleted.ProductID INTO dsi.temp_products";
ms_and_generic().verified_stmt(stmt);
}
#[test]
fn parse_drop_trigger() {
let sql_drop_trigger = "DROP TRIGGER emp_stamp;";
let drop_stmt = ms().one_statement_parses_to(sql_drop_trigger, "");
assert_eq!(
drop_stmt,
Statement::DropTrigger {
if_exists: false,
trigger_name: ObjectName::from(vec![Ident::new("emp_stamp")]),
table_name: None,
option: None,
}
);
}