sqlparser/dialect/
sqlite.rs1#[cfg(not(feature = "std"))]
19use alloc::boxed::Box;
20
21use crate::ast::BinaryOperator;
22use crate::ast::{Expr, Statement};
23use crate::dialect::Dialect;
24use crate::keywords::Keyword;
25use crate::parser::{Parser, ParserError};
26
27#[derive(#[automatically_derived]
impl ::core::fmt::Debug for SQLiteDialect {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f, "SQLiteDialect")
}
}Debug, #[automatically_derived]
impl ::core::default::Default for SQLiteDialect {
#[inline]
fn default() -> SQLiteDialect { SQLiteDialect {} }
}Default, #[automatically_derived]
impl ::core::clone::Clone for SQLiteDialect {
#[inline]
fn clone(&self) -> SQLiteDialect { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for SQLiteDialect { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for SQLiteDialect {
#[inline]
fn eq(&self, other: &SQLiteDialect) -> bool { true }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for SQLiteDialect {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {}
}Eq, #[automatically_derived]
impl ::core::hash::Hash for SQLiteDialect {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {}
}Hash, #[automatically_derived]
impl ::core::cmp::PartialOrd for SQLiteDialect {
#[inline]
fn partial_cmp(&self, other: &SQLiteDialect)
-> ::core::option::Option<::core::cmp::Ordering> {
::core::option::Option::Some(::core::cmp::Ordering::Equal)
}
}PartialOrd, #[automatically_derived]
impl ::core::cmp::Ord for SQLiteDialect {
#[inline]
fn cmp(&self, other: &SQLiteDialect) -> ::core::cmp::Ordering {
::core::cmp::Ordering::Equal
}
}Ord)]
34#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
35pub struct SQLiteDialect {}
36
37impl Dialect for SQLiteDialect {
38 fn is_delimited_identifier_start(&self, ch: char) -> bool {
42 ch == '`' || ch == '"' || ch == '['
43 }
44
45 fn identifier_quote_style(&self, _identifier: &str) -> Option<char> {
46 Some('`')
47 }
48
49 fn is_identifier_start(&self, ch: char) -> bool {
50 ch.is_ascii_lowercase()
52 || ch.is_ascii_uppercase()
53 || ch == '_'
54 || ('\u{007f}'..='\u{ffff}').contains(&ch)
55 }
56
57 fn supports_filter_during_aggregation(&self) -> bool {
58 true
59 }
60
61 fn supports_start_transaction_modifier(&self) -> bool {
62 true
63 }
64
65 fn is_identifier_part(&self, ch: char) -> bool {
66 self.is_identifier_start(ch) || ch.is_ascii_digit()
67 }
68
69 fn parse_statement(&self, parser: &mut Parser) -> Option<Result<Statement, ParserError>> {
70 if parser.parse_keyword(Keyword::REPLACE) {
71 parser.prev_token();
72 Some(parser.parse_insert(parser.get_current_token().clone()))
73 } else {
74 None
75 }
76 }
77
78 fn parse_infix(
79 &self,
80 parser: &mut crate::parser::Parser,
81 expr: &crate::ast::Expr,
82 _precedence: u8,
83 ) -> Option<Result<crate::ast::Expr, ParserError>> {
84 for (keyword, op) in [
87 (Keyword::REGEXP, BinaryOperator::Regexp),
88 (Keyword::MATCH, BinaryOperator::Match),
89 ] {
90 if parser.parse_keyword(keyword) {
91 let left = Box::new(expr.clone());
92 let right = Box::new(parser.parse_expr().unwrap());
93 return Some(Ok(Expr::BinaryOp { left, op, right }));
94 }
95 }
96 None
97 }
98
99 fn supports_in_empty_list(&self) -> bool {
100 true
101 }
102
103 fn supports_limit_comma(&self) -> bool {
104 true
105 }
106
107 fn supports_asc_desc_in_column_definition(&self) -> bool {
108 true
109 }
110
111 fn supports_dollar_placeholder(&self) -> bool {
112 true
113 }
114
115 fn supports_notnull_operator(&self) -> bool {
118 true
119 }
120}