bindAsParameters method
void
bindAsParameters(
- CommonPreparedStatement stmt
Implementation
void bindAsParameters(CommonPreparedStatement stmt) {
final expectedParameterCount = stmt.parameterCount;
final actualLength = length;
if (actualLength != expectedParameterCount) {
throw ArgumentError(
'Expected $expectedParameterCount parameters, got $actualLength',
);
}
final raw = stmt.raw;
raw.debugParameters = this;
for (var i = 0; i < actualLength; i++) {
final code = TypeCode.of(_types[i]);
final sqliteIndex = i + 1;
final rawValue = _array[i];
switch (code) {
case TypeCode.integer:
raw.bindInt64(sqliteIndex, (rawValue as JSNumber).toDartInt);
case TypeCode.bigInt:
raw.bindJSBigInt(sqliteIndex, rawValue as JSBigInt);
case TypeCode.float:
raw.bindDouble(sqliteIndex, (rawValue as JSNumber).toDartDouble);
case TypeCode.text:
raw.bindText(sqliteIndex, (rawValue as JSString).toDart);
case TypeCode.blob:
raw.bindBlob(sqliteIndex, (rawValue as JSUint8Array).toDart);
case TypeCode.$null:
raw.bindNull(sqliteIndex);
case TypeCode.boolean:
raw.bindInt64(sqliteIndex, (rawValue as JSBoolean).toDart ? 1 : 0);
case TypeCode.unknown:
throw UnsupportedError('Unknown type code');
}
}
}