@@ -303,6 +303,80 @@ void main() {
303303 )
304304 });
305305
306+ test ('execute single statement with RETURNING populates ResultSet' ,
307+ () async {
308+ final db = await testUtils.setupDatabase (path: path);
309+ await createTables (db);
310+ final result = await db.execute (
311+ 'INSERT INTO test_data(description) VALUES(?) RETURNING id, description' ,
312+ ['test returning with params' ]);
313+
314+ expect (result.columnNames, equals (['id' , 'description' ]));
315+ expect (result.rows.length, equals (1 ));
316+ expect (result.rows[0 ][0 ], isA <int >());
317+ expect (result.rows[0 ][1 ], equals ('test returning with params' ));
318+ });
319+
320+ test (
321+ 'execute single statment with RETURNING populates ResultSet without params' ,
322+ () async {
323+ final db = await testUtils.setupDatabase (path: path);
324+ await createTables (db);
325+ final result = await db.execute (
326+ "INSERT INTO test_data(description) VALUES('test returning without params') RETURNING id, description" );
327+
328+ expect (result.columnNames, equals (['id' , 'description' ]));
329+ expect (result.rows.length, equals (1 ));
330+ expect (result.rows[0 ][0 ], isA <int >());
331+ expect (result.rows[0 ][1 ], equals ('test returning without params' ));
332+ });
333+
334+ test ('executeMultiple handles multiple statements' , () async {
335+ final db = await testUtils.setupDatabase (path: path);
336+ await createTables (db);
337+
338+ await db.executeMultiple ('''
339+ INSERT INTO test_data(description) VALUES('row1');
340+ INSERT INTO test_data(description) VALUES('row2');
341+ ''' );
342+
343+ final results =
344+ await db.getAll ('SELECT description FROM test_data ORDER BY id' );
345+ expect (results.length, equals (2 ));
346+ expect (results.rows[0 ], equals (['row1' ]));
347+ expect (results.rows[1 ], equals (['row2' ]));
348+
349+ await db.close ();
350+ });
351+
352+ test ('executeMultiple rolls back on failure' , () async {
353+ final db = await testUtils.setupDatabase (path: path);
354+ await createTables (db);
355+
356+ // Insert an initial row with id=1
357+ await db.execute ('INSERT INTO test_data(id, description) VALUES(?, ?)' ,
358+ [1 , 'initial' ]);
359+
360+ // Attempt executeMultiple where second statement fails due to duplicate primary key
361+ await expectLater (
362+ db.executeMultiple ('''
363+ INSERT INTO test_data(id, description) VALUES(2, 'should_rollback');
364+ INSERT INTO test_data(id, description) VALUES(1, 'duplicate_key');
365+ ''' ),
366+ throwsA (isA <SqliteException >()),
367+ );
368+
369+ // Verify only the initial row exists - the first insert in
370+ // executeMultiple should have been rolled back.
371+ final results =
372+ await db.getAll ('SELECT id, description FROM test_data ORDER BY id' );
373+ expect (results, [
374+ {'id' : 1 , 'description' : 'initial' }
375+ ]);
376+
377+ await db.close ();
378+ });
379+
306380 test ('with all connections' , () async {
307381 final maxReaders = _isWeb ? 0 : 3 ;
308382
0 commit comments