Skip to content

Commit ea80f04

Browse files
committed
Simplify slightly
1 parent aa76bfe commit ea80f04

2 files changed

Lines changed: 20 additions & 16 deletions

File tree

crates/core/src/crud_vtab.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use alloc::boxed::Box;
44
use alloc::rc::Rc;
55
use const_format::formatcp;
66
use core::ffi::{CStr, c_char, c_int, c_void};
7-
use core::mem;
87
use serde::Serialize;
98
use serde_json::value::RawValue;
109

@@ -227,7 +226,7 @@ impl VirtualTable {
227226
}
228227

229228
fn end_transaction(&mut self) {
230-
if let Some(tx) = mem::take(&mut self.current_tx) {
229+
if let Some(tx) = self.current_tx.take() {
231230
if tx.observed_begin {
232231
self.state.current_transaction_id.set(None);
233232
}

dart/test/crud_test.dart

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,21 +1022,26 @@ INSERT INTO ps_kv(key, value) VALUES
10221022
});
10231023
}
10241024

1025-
test('for writes in both types of tables', () {
1026-
for (var tx = 1; tx < 10; tx++) {
1027-
db.execute('BEGIN');
1028-
for (var i = 0; i < tx; i++) {
1029-
db.execute('INSERT INTO regular (id, a) VALUES (uuid(), 1234)');
1030-
db.execute('INSERT INTO insertonly (id, a) VALUES (uuid(), 1234)');
1031-
}
1032-
db.execute('COMMIT');
1025+
for (final (first, second) in [
1026+
('regular', 'insertonly'),
1027+
('insertonly', 'regular')
1028+
]) {
1029+
test('write $first then $second', () {
1030+
for (var tx = 1; tx < 10; tx++) {
1031+
db.execute('BEGIN');
1032+
for (var i = 0; i < tx; i++) {
1033+
db.execute('INSERT INTO $first (id, a) VALUES (uuid(), 1234)');
1034+
db.execute('INSERT INTO $second (id, a) VALUES (uuid(), 1234)');
1035+
}
1036+
db.execute('COMMIT');
10331037

1034-
expect(
1035-
db.select('SELECT * FROM ps_crud WHERE tx_id = ?', [tx]),
1036-
hasLength(tx * 2),
1037-
);
1038-
}
1039-
});
1038+
expect(
1039+
db.select('SELECT * FROM ps_crud WHERE tx_id = ?', [tx]),
1040+
hasLength(tx * 2),
1041+
);
1042+
}
1043+
});
1044+
}
10401045
});
10411046
});
10421047
}

0 commit comments

Comments
 (0)