MCPcopy Create free account
hub / github.com/PRQL/prql / is_keyword

Function is_keyword

prqlc/prqlc/src/sql/keywords.rs:15–19  ·  view source on GitHub ↗

True for keywords which we want to quote when translating to SQL. Currently we're being fairly permissive (over-quoting is not a big concern). We're not including the full list from `SQL_KEYWORDS`, as that has terms such as `ID`, instead we bring a few dialects' keywords in.

(ident: &str, dialect: &Dialect)

Source from the content-addressed store, hash-verified

13// We're not including the full list from `SQL_KEYWORDS`, as that has terms such
14// as `ID`, instead we bring a few dialects' keywords in.
15pub(super) fn is_keyword(ident: &str, dialect: &Dialect) -> bool {
16 let ident = ident.to_ascii_uppercase();
17
18 sql_keywords().contains(ident.as_str()) || dialect_keywords(dialect).contains(ident.as_str())
19}
20
21fn dialect_keywords(dialect: &Dialect) -> &'static HashSet<&'static str> {
22 match dialect {

Callers 1

translate_ident_partFunction · 0.85

Calls 3

sql_keywordsFunction · 0.85
dialect_keywordsFunction · 0.85
as_strMethod · 0.80

Tested by

no test coverage detected