From 6d649237a4dae8cc6a1537902c1cfd8a3870243d Mon Sep 17 00:00:00 2001 From: Christian Schneider Date: Mon, 3 Oct 2022 16:01:49 +0200 Subject: Fix it_dbi being used with it::map/iterator_to_array --- it_dbi.class | 2 +- test/it_dbi.t | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/it_dbi.class b/it_dbi.class index 9603105..e78523b 100644 --- a/it_dbi.class +++ b/it_dbi.class @@ -1023,7 +1023,7 @@ static function _state_purgeshared($dbid = null) #[ReturnTypeWillChange] function current() { - return $this; + return clone $this; } #[ReturnTypeWillChange] diff --git a/test/it_dbi.t b/test/it_dbi.t index b35c97d..2b5b0c5 100755 --- a/test/it_dbi.t +++ b/test/it_dbi.t @@ -444,6 +444,10 @@ $record->upsert(['ID' => 3, 'foo' => "c"]); is($record->delete_untouched([ 'ID >' => 2 ]), [], 'delete_untouched with query'); is(allrecs(), '[{"ID":1,"foo":"A"},{"ID":2,"foo":"B"},{"ID":3,"foo":"c"}]', 'data after delete_untouched with query'); +# Test it::map with it_dbi (clone vs. reference issue) +is(it::map('$v->foo', new it_dbi_test(['ID' => [1, 2, 3]])), [1 => 'A', 2 => 'B', 3 => 'c'], 'it_dbi with it::map'); +is(it::map('$v->foo', iterator_to_array(new it_dbi_test(['ID' => [1, 2, 3]]))), [1 => 'A', 2 => 'B', 3 => 'c'], 'it_dbi with iterator_to_array'); + $record->upsert(['ID' => 3, 'foo' => "C"]); is(it::sort($record->delete_untouched()), [1, 2], 'delete_untouched with query'); is(allrecs(), '[{"ID":3,"foo":"C"}]', 'data after delete_untouched with query'); -- cgit v1.2.3