sqlIdentifier function

String sqlIdentifier(
  1. String name
)

Escapes and quotes a non-empty String for use as an SQLite identifier.

This function uses backticks for quoting instead of double quotes. This is done to prevent the possibility of SQLite reinterpreting a double-quoted identifier as a string literal.

Implementation

String sqlIdentifier(String name) {
  checkState(name.isNotEmpty, message: "sqlIdentifier: empty name");
  raiseOnNul("sqlIdentifier", name);
  return "`${name.replaceAll("`", "``")}`";
}