mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-14 19:20:15 +00:00
Add MSSQL dialect and fix up the postgres' identifier rules
The `@@version` test is MS' dialect of SQL, it seems, so test it with
its own dialect.
Update the rules for identifiers in Postresql dialect per documentation,
while we're at it. The current identifier rules in Postgresql dialect
were introduced in this commit - as a copy of generic rules, it seems:
810cd8e6cf (diff-2808df0fba0aed85f9d35c167bd6a5f1L138)
This commit is contained in:
parent
5047f2c02e
commit
304710d59a
8 changed files with 75 additions and 15 deletions
22
src/dialect/mssql.rs
Normal file
22
src/dialect/mssql.rs
Normal file
|
@ -0,0 +1,22 @@
|
|||
use crate::dialect::Dialect;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct MsSqlDialect {}
|
||||
|
||||
impl Dialect for MsSqlDialect {
|
||||
fn is_identifier_start(&self, ch: char) -> bool {
|
||||
// See https://docs.microsoft.com/en-us/sql/relational-databases/databases/database-identifiers?view=sql-server-2017#rules-for-regular-identifiers
|
||||
// We don't support non-latin "letters" currently.
|
||||
(ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || ch == '_' || ch == '#' || ch == '@'
|
||||
}
|
||||
|
||||
fn is_identifier_part(&self, ch: char) -> bool {
|
||||
(ch >= 'a' && ch <= 'z')
|
||||
|| (ch >= 'A' && ch <= 'Z')
|
||||
|| (ch >= '0' && ch <= '9')
|
||||
|| ch == '@'
|
||||
|| ch == '$'
|
||||
|| ch == '#'
|
||||
|| ch == '_'
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue