Skip to content

Commit 7d6ed34

Browse files
committed
Keep last $dbh.rows after $sth.dispose
1 parent cefb547 commit 7d6ed34

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

lib/DBDish/Connection.pm6

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ unit role DBDish::Connection does DBDish::ErrorHandling;
1919

2020
has %.Statements;
2121
has $.last-sth-id is rw;
22+
has $.last-rows is rw;
2223

2324
method dispose() {
2425
$_.dispose for %!Statements.values;
@@ -60,6 +61,8 @@ method rows {
6061
if $!last-sth-id {
6162
with %!Statements{$!last-sth-id} {
6263
.rows;
64+
} else {
65+
$!last-rows
6366
}
6467
}
6568
}

lib/DBDish/StatementHandle.pm6

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,10 @@ method new(*%args) {
5555
method dispose() {
5656
self.finish unless $!Finished;
5757
self._free;
58-
my \id := self.WHICH.Str;
59-
?($.parent.Statements{id}:delete);
58+
with $.parent.Statements{self.WHICH}:delete {
59+
$.parent.last-rows = self.rows;
60+
True;
61+
} else { False };
6062
}
6163
#Avoid leaks if explicit dispose isn't used by the user.
6264
submethod DESTROY() {

0 commit comments

Comments
 (0)