Skip to content

Commit 926b4fd

Browse files
committed
fix: begin atomic split
1 parent df6abda commit 926b4fd

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

crates/pgt_statement_splitter/src/lib.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,30 @@ mod tests {
133133
}
134134
}
135135

136+
#[test]
137+
fn begin_atomic() {
138+
Tester::from(
139+
"CREATE OR REPLACE FUNCTION public.test_fn(some_in TEXT)
140+
RETURNS TEXT
141+
LANGUAGE sql
142+
IMMUTABLE
143+
STRICT
144+
BEGIN ATOMIC
145+
SELECT $1 || 'foo';
146+
END;",
147+
)
148+
.expect_statements(vec![
149+
"CREATE OR REPLACE FUNCTION public.test_fn(some_in TEXT)
150+
RETURNS TEXT
151+
LANGUAGE sql
152+
IMMUTABLE
153+
STRICT
154+
BEGIN ATOMIC
155+
SELECT $1 || 'foo';
156+
END;",
157+
]);
158+
}
159+
136160
#[test]
137161
fn ts_with_timezone() {
138162
Tester::from("alter table foo add column bar timestamp with time zone;").expect_statements(

crates/pgt_statement_splitter/src/splitter/common.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ pub(crate) fn unknown(p: &mut Splitter, exclude: &[SyntaxKind]) {
188188
// for revoke
189189
SyntaxKind::REVOKE_KW,
190190
SyntaxKind::COMMA,
191+
// for BEGIN ATOMIC
192+
SyntaxKind::ATOMIC_KW,
191193
]
192194
.iter()
193195
.all(|x| Some(x) != prev.as_ref())

0 commit comments

Comments
 (0)