-
Notifications
You must be signed in to change notification settings - Fork 15
Description
All methods in this package only support executing a single statement. While obviously
you can work around this by manually splitting out SQL or a potentially sketchy .split(';'),
those are inconvieint and error-prone.
I'd like to do something like:
final migration = await File("./assets/ddl/$fname").readAsString();
await db.execute(script); // only supports 1 statement!Currently:
executecallsselectunder the hood- and
executeBatchdoespreparethenstatement.execute().
We need something that uses prepareMultiple.
For web: https://github.com/simolus3/sqlite3.dart/blob/v2/lib/src/worker.dart#L345
API Options
1. New method with no parameters
Future<void> executeMultiple(String sql)
// or
Future<void> executeRaw(String sql)Why didn't I include a List<List<Object?>> parameterSets or even a flat List<Object?>?
It's pretty ambigious how that should be handled with multiple statements:
- Do we apply every parameter set to every statement?
- Do we apply
parameterSets[n]tostatements[n]? - If
parameterSets.length != statements.length, is that an error?
IIUC adding optional parameters is not a breaking change, so that could be added later.
2. Modify executeBatch behavior
Current implementation uses .prepare, could switch to .prepareMultiple and execute statements sequentially (stop on first error).
Breaking change risk: Users unknowingly passing multiple statements who rely on only the first executing.
Could make explicit:
Future<void> executeBatch(
String sql,
List<List<Object?>> parameterSets, {
bool allowMultipleStatements = true,
})