pragmaStatements method

List<String> pragmaStatements(
  1. SqliteOpenOptions options
)

Implementation

List<String> pragmaStatements(SqliteOpenOptions options) {
  List<String> statements = [];

  if (sqliteOptions.lockTimeout != null) {
    // May be replaced by a Dart-level retry mechanism in the future
    statements.add(
        'PRAGMA busy_timeout = ${sqliteOptions.lockTimeout!.inMilliseconds}');
  }

  if (options.primaryConnection && sqliteOptions.journalMode != null) {
    // Persisted - only needed on the primary connection
    statements
        .add('PRAGMA journal_mode = ${sqliteOptions.journalMode!.name}');
  }
  if (!options.readOnly && sqliteOptions.journalSizeLimit != null) {
    // Needed on every writable connection
    statements.add(
        'PRAGMA journal_size_limit = ${sqliteOptions.journalSizeLimit!}');
  }
  if (sqliteOptions.synchronous != null) {
    // Needed on every connection
    statements.add('PRAGMA synchronous = ${sqliteOptions.synchronous!.name}');
  }
  return statements;
}