$expandVar method

String $expandVar(
  1. int start,
  2. int amount
)
inherited

Used by generated code to expand array variables.

Implementation

String $expandVar(int start, int amount) {
  final buffer = StringBuffer();

  final variableSymbol = switch (executor.dialect) {
    SqlDialect.postgres => r'$',
    _ => '?',
  };
  final supportsIndexedParameters =
      executor.dialect.supportsIndexedParameters;

  for (var x = 0; x < amount; x++) {
    if (supportsIndexedParameters) {
      buffer.write('$variableSymbol${start + x}');
    } else {
      buffer.write(variableSymbol);
    }

    if (x != amount - 1) {
      buffer.write(', ');
    }
  }

  return buffer.toString();
}