Redshift - Add support in sharp as start of the field name (#485)

* Add support in sharp

* CR Review
This commit is contained in:
yuval-illumex 2022-05-10 13:34:01 +03:00 committed by GitHub
parent ed86c6d53d
commit 35f5f0be4d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View file

@ -44,10 +44,12 @@ impl Dialect for RedshiftSqlDialect {
}
fn is_identifier_start(&self, ch: char) -> bool {
PostgreSqlDialect {}.is_identifier_start(ch)
// Extends Postgres dialect with sharp
PostgreSqlDialect {}.is_identifier_start(ch) || ch == '#'
}
fn is_identifier_part(&self, ch: char) -> bool {
PostgreSqlDialect {}.is_identifier_part(ch)
// Extends Postgres dialect with sharp
PostgreSqlDialect {}.is_identifier_part(ch) || ch == '#'
}
}

View file

@ -100,3 +100,13 @@ fn redshift() -> TestedDialects {
dialects: vec![Box::new(RedshiftSqlDialect {})],
}
}
#[test]
fn test_sharp() {
let sql = "SELECT #_of_values";
let select = redshift().verified_only_select(sql);
assert_eq!(
SelectItem::UnnamedExpr(Expr::Identifier(Ident::new("#_of_values"))),
select.projection[0]
);
}