checkMaxSqlParameters method

Future<void> checkMaxSqlParameters()

Implementation

Future<void> checkMaxSqlParameters() async {
  if (builder.dialect == Dialect.sqlite) {
    final version = (await adapter.query(
      Statement(
        'SELECT sqlite_version() AS version',
      ),
    ))
        .first['version']! as String;

    final [major, minor, ...] =
        version.split('.').map((x) => int.parse(x)).toList();

    if (major == 3 && minor >= 32) {
      maxSqlParameters = 32766;
    } else {
      maxSqlParameters = 999;
    }
  } else {
    // Postgres allows a maximum of 65535 query parameters
    maxSqlParameters = 65535;
  }
}