Skip to content

Commit 3818bbc

Browse files
committed
feat: add support for truncate statement
1 parent bbc24cc commit 3818bbc

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

Diff for: crates/codegen/src/get_node_properties.rs

+17
Original file line numberDiff line numberDiff line change
@@ -952,6 +952,23 @@ fn custom_handlers(node: &Node) -> TokenStream {
952952
}
953953
}
954954
},
955+
"TruncateStmt" => quote! {
956+
tokens.push(TokenProperty::from(Token::Truncate));
957+
if n.restart_seqs {
958+
tokens.push(TokenProperty::from(Token::Restart));
959+
tokens.push(TokenProperty::from(Token::IdentityP));
960+
} else {
961+
tokens.push(TokenProperty::from(Token::ContinueP));
962+
tokens.push(TokenProperty::from(Token::IdentityP));
963+
}
964+
match n.behavior {
965+
// DropRestrict
966+
1 => tokens.push(TokenProperty::from(Token::Restrict)),
967+
// DropCascade
968+
2 => tokens.push(TokenProperty::from(Token::Cascade)),
969+
_ => {}
970+
}
971+
},
955972
_ => quote! {},
956973
}
957974
}

Diff for: crates/parser/src/codegen.rs

+14
Original file line numberDiff line numberDiff line change
@@ -358,4 +358,18 @@ mod tests {
358358
],
359359
)
360360
}
361+
362+
#[test]
363+
fn test_truncate() {
364+
test_get_node_properties(
365+
"TRUNCATE TABLE users CONTINUE IDENTITY RESTRICT",
366+
SyntaxKind::TruncateStmt,
367+
vec![
368+
TokenProperty::from(SyntaxKind::Truncate),
369+
TokenProperty::from(SyntaxKind::ContinueP),
370+
TokenProperty::from(SyntaxKind::IdentityP),
371+
TokenProperty::from(SyntaxKind::Restrict),
372+
],
373+
)
374+
}
361375
}

0 commit comments

Comments
 (0)