diff --git a/core/translate/mod.rs b/core/translate/mod.rs index 1f40c3f02..04e0e3af2 100644 --- a/core/translate/mod.rs +++ b/core/translate/mod.rs @@ -548,7 +548,7 @@ fn translate_pragma( let pragma = match PragmaName::from_str(&name.name.0) { Ok(pragma) => pragma, - Err(()) => bail_parse_error!("Not a valid pragma name"), + Err(_) => bail_parse_error!("Not a valid pragma name"), }; match body { diff --git a/vendored/sqlite3-parser/Cargo.toml b/vendored/sqlite3-parser/Cargo.toml index 9b8513f74..b446e9ba4 100644 --- a/vendored/sqlite3-parser/Cargo.toml +++ b/vendored/sqlite3-parser/Cargo.toml @@ -32,6 +32,8 @@ bitflags = "2.0" uncased = "0.9.10" indexmap = "2.0" miette = "7.4.0" +strum = { version = "0.26", features = ["derive"] } +strum_macros = "0.26" [dev-dependencies] env_logger = { version = "0.11", default-features = false } diff --git a/vendored/sqlite3-parser/src/parser/ast/mod.rs b/vendored/sqlite3-parser/src/parser/ast/mod.rs index f46f38e85..93bf05bee 100644 --- a/vendored/sqlite3-parser/src/parser/ast/mod.rs +++ b/vendored/sqlite3-parser/src/parser/ast/mod.rs @@ -7,6 +7,8 @@ use std::num::ParseIntError; use std::ops::Deref; use std::str::{self, Bytes, FromStr}; +use strum_macros::{EnumIter, EnumString}; + use fmt::{ToTokens, TokenStream}; use indexmap::{IndexMap, IndexSet}; @@ -1585,7 +1587,8 @@ pub type PragmaValue = Expr; // TODO /// `PRAGMA` value // https://sqlite.org/pragma.html -#[derive(Clone, Debug, PartialEq, Eq)] +#[derive(Clone, Debug, PartialEq, Eq, EnumIter, EnumString, strum::Display)] +#[strum(serialize_all = "snake_case")] pub enum PragmaName { /// `cache_size` pragma CacheSize, @@ -1597,20 +1600,6 @@ pub enum PragmaName { TableInfo, } -impl FromStr for PragmaName { - type Err = (); - - fn from_str(input: &str) -> Result { - match input { - "cache_size" => Ok(PragmaName::CacheSize), - "wal_checkpoint" => Ok(PragmaName::WalCheckpoint), - "journal_mode" => Ok(PragmaName::JournalMode), - "table_info" => Ok(PragmaName::TableInfo), - _ => Err(()), - } - } -} - /// `CREATE TRIGGER` time #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum TriggerTime {