completely remove usage of enum variants

This commit is contained in:
Nikita Sivukhin
2025-09-25 18:27:14 +04:00
parent 9f2f8438e0
commit f3f9219795
8 changed files with 64 additions and 58 deletions

View File

@@ -891,6 +891,9 @@ impl Name {
pub fn exact(s: String) -> Self {
Self::Ident(s)
}
pub fn from_bytes(s: &[u8]) -> Self {
Self::new(unsafe { std::str::from_utf8_unchecked(s) }.to_owned())
}
pub fn new(s: impl AsRef<str>) -> Self {
let s = s.as_ref();
let bytes = s.as_bytes();
@@ -911,13 +914,27 @@ impl Name {
}
}
/// Checks if a name represents a double-quoted string that should get fallback behavior
pub fn is_double_quoted(&self) -> bool {
pub fn as_literal(&self) -> &str {
match self {
Name::Ident(s) | Name::Quoted(s) => s.as_str(),
}
}
/// Checks if a name represents a quoted string that should get fallback behavior
/// Need to detect legacy conversion of double quoted keywords to string literals
/// (see https://sqlite.org/lang_keywords.html)
///
/// Also, used to detect string literals in PRAGMA cases
pub fn quoted_with(&self, quote: char) -> bool {
if let Self::Quoted(ident) = self {
return ident.starts_with("\"");
return ident.starts_with(quote);
}
false
}
pub fn quoted(&self) -> bool {
matches!(self, Self::Quoted(..))
}
}
/// Qualified name