Skip to content

Commit c5357bf

Browse files
author
Takahiro Ebato
committed
fix tests and documentation
1 parent f2ad35e commit c5357bf

File tree

3 files changed

+17
-56
lines changed

3 files changed

+17
-56
lines changed

src/ast/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4299,9 +4299,9 @@ impl fmt::Display for TransactionIsolationLevel {
42994299
}
43004300
}
43014301

4302-
/// Sqlite specific syntax
4302+
/// SQLite specific syntax
43034303
///
4304-
/// https://sqlite.org/lang_transaction.html
4304+
/// <https://sqlite.org/lang_transaction.html>
43054305
#[derive(Debug, Copy, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
43064306
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
43074307
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]

src/test_utils.rs

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -212,50 +212,6 @@ pub fn all_dialects() -> TestedDialects {
212212
}
213213
}
214214

215-
static ALL_DIALECT_NAMES: &[&str] = &[
216-
"generic",
217-
"mysql",
218-
"postgresql",
219-
"hive",
220-
"sqlite",
221-
"snowflake",
222-
"redshift",
223-
"mssql",
224-
"clickhouse",
225-
"bigquery",
226-
"ansi",
227-
"duckdb",
228-
];
229-
230-
pub fn partition_all_dialects_by_inclusion(
231-
dialect_names: Vec<&str>,
232-
) -> (TestedDialects, TestedDialects) {
233-
for dialect_name in &dialect_names {
234-
assert!(
235-
ALL_DIALECT_NAMES.contains(dialect_name),
236-
"Unknown dialect: {}",
237-
dialect_name
238-
);
239-
}
240-
241-
let (included_dialect_names, excluded_dialect_names) = ALL_DIALECT_NAMES
242-
.iter()
243-
.partition(|&dialect_name| dialect_names.contains(dialect_name));
244-
245-
let build_tested_dialects = |names: Vec<&str>| TestedDialects {
246-
dialects: names
247-
.iter()
248-
.map(|&name| dialect_from_str(name).unwrap())
249-
.collect(),
250-
options: None,
251-
};
252-
253-
(
254-
build_tested_dialects(included_dialect_names),
255-
build_tested_dialects(excluded_dialect_names),
256-
)
257-
}
258-
259215
pub fn assert_eq_vec<T: ToString>(expected: &[&str], actual: &[T]) {
260216
assert_eq!(
261217
expected,

tests/sqlparser_sqlite.rs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -433,16 +433,21 @@ fn invalid_empty_list() {
433433

434434
#[test]
435435
fn parse_start_transaction_with_modifier() {
436-
let (supported_dialects, unsupported_dialects) =
437-
partition_all_dialects_by_inclusion(vec!["generic", "sqlite"]);
438-
439-
supported_dialects.verified_stmt("BEGIN DEFERRED TRANSACTION");
440-
supported_dialects.verified_stmt("BEGIN IMMEDIATE TRANSACTION");
441-
supported_dialects.verified_stmt("BEGIN EXCLUSIVE TRANSACTION");
442-
supported_dialects.one_statement_parses_to("BEGIN DEFERRED", "BEGIN DEFERRED TRANSACTION");
443-
supported_dialects.one_statement_parses_to("BEGIN IMMEDIATE", "BEGIN IMMEDIATE TRANSACTION");
444-
supported_dialects.one_statement_parses_to("BEGIN EXCLUSIVE", "BEGIN EXCLUSIVE TRANSACTION");
445-
436+
sqlite_and_generic().verified_stmt("BEGIN DEFERRED TRANSACTION");
437+
sqlite_and_generic().verified_stmt("BEGIN IMMEDIATE TRANSACTION");
438+
sqlite_and_generic().verified_stmt("BEGIN EXCLUSIVE TRANSACTION");
439+
sqlite_and_generic().one_statement_parses_to("BEGIN DEFERRED", "BEGIN DEFERRED TRANSACTION");
440+
sqlite_and_generic().one_statement_parses_to("BEGIN IMMEDIATE", "BEGIN IMMEDIATE TRANSACTION");
441+
sqlite_and_generic().one_statement_parses_to("BEGIN EXCLUSIVE", "BEGIN EXCLUSIVE TRANSACTION");
442+
443+
let unsupported_dialects = TestedDialects {
444+
dialects: all_dialects()
445+
.dialects
446+
.into_iter()
447+
.filter(|x| !(x.is::<SQLiteDialect>() || x.is::<GenericDialect>()))
448+
.collect(),
449+
options: None,
450+
};
446451
let res = unsupported_dialects.parse_sql_statements("BEGIN DEFERRED");
447452
assert_eq!(
448453
ParserError::ParserError("Expected end of statement, found: DEFERRED".to_string()),

0 commit comments

Comments
 (0)