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:
Nickolay Ponomarev 2019-05-03 03:09:44 +03:00
parent 5047f2c02e
commit 304710d59a
8 changed files with 75 additions and 15 deletions

View file

@ -5,14 +5,17 @@ pub struct PostgreSqlDialect {}
impl Dialect for PostgreSqlDialect {
fn is_identifier_start(&self, ch: char) -> bool {
(ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || ch == '@'
// See https://www.postgresql.org/docs/11/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS
// We don't yet support identifiers beginning with "letters with
// diacritical marks and non-Latin letters"
(ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || ch == '_'
}
fn is_identifier_part(&self, ch: char) -> bool {
(ch >= 'a' && ch <= 'z')
|| (ch >= 'A' && ch <= 'Z')
|| (ch >= '0' && ch <= '9')
|| ch == '@'
|| ch == '$'
|| ch == '_'
}
}