mapToSqlConstant method

  1. @override
String mapToSqlConstant(
  1. String? content
)
override

Maps the given content to a sql literal that can be included in the query string.

Implementation

@override
String mapToSqlConstant(String? content) {
  if (content == null) return 'NULL';

  // From the sqlite docs: (https://www.sqlite.org/lang_expr.html)
  // A string constant is formed by enclosing the string in single quotes (').
  // A single quote within the string can be encoded by putting two single
  // quotes in a row - as in Pascal. C-style escapes using the backslash
  // character are not supported because they are not standard SQL.
  final escapedChars = content.replaceAll('\'', '\'\'');
  return "'$escapedChars'";
}