Skip to content

Commit c22a78d

Browse files
committed
test: Add word-boundary and leading-whitespace tests for PRAGMA detection
Mirror the existing test_not_select_if_part_of_word / test_not_cte_if_part_of_word and test_explain_with_whitespace patterns for the PRAGMA branch of should_use_query: - test_not_pragma_if_part_of_word: asserts that "PRAGMATIC" and similar strings do NOT match, confirming the word-boundary guard is enforced. - test_pragma_with_whitespace: asserts that leading spaces, tabs, and newlines before PRAGMA are correctly skipped by skip_whitespace_and_comments.
1 parent a5f79ce commit c22a78d

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

native/ecto_libsql/src/tests/utils_tests.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,21 @@ mod should_use_query_tests {
270270
assert!(should_use_query("PRAGMA foreign_keys"));
271271
}
272272

273+
#[test]
274+
fn test_not_pragma_if_part_of_word() {
275+
// "PRAGMATIC" and similar should not match PRAGMA.
276+
assert!(!should_use_query("PRAGMATIC table_name"));
277+
assert!(!should_use_query("PRAGMATICS"));
278+
}
279+
280+
#[test]
281+
fn test_pragma_with_whitespace() {
282+
// Leading whitespace before PRAGMA must be skipped correctly.
283+
assert!(should_use_query(" PRAGMA foreign_keys"));
284+
assert!(should_use_query("\tPRAGMA journal_mode"));
285+
assert!(should_use_query("\n PRAGMA wal_checkpoint(FULL)"));
286+
}
287+
273288
// ===== Edge Cases =====
274289

275290
#[test]

0 commit comments

Comments
 (0)