escapeIfNeeded function
Escapes s
by wrapping it in backticks if it's an sqlite keyword.
Implementation
String escapeIfNeeded(String s, [SqlDialect dialect = SqlDialect.sqlite]) {
final inUpperCase = s.toUpperCase();
var isKeyword = baseKeywords.contains(inUpperCase);
if (dialect == SqlDialect.postgres) {
isKeyword |= additionalPostgresKeywords.contains(inUpperCase);
}
if (dialect == SqlDialect.mariadb) {
isKeyword |= additionalMariaDBKeywords.contains(inUpperCase);
}
if (isKeyword || _notInKeyword.hasMatch(s)) return dialect.escape(s);
return s;
}