diff options
author | Christian Schneider | 2022-10-03 16:01:49 +0200 |
---|---|---|
committer | Christian Schneider | 2022-10-03 16:01:49 +0200 |
commit | 6d649237a4dae8cc6a1537902c1cfd8a3870243d (patch) | |
tree | 46c7cdc97f250a0a76fcd9a12562cd17010fcb04 | |
parent | 53db056c0fa24c1c8539a36002a3009f6a15bfa1 (diff) | |
download | itools-6d649237a4dae8cc6a1537902c1cfd8a3870243d.tar.gz itools-6d649237a4dae8cc6a1537902c1cfd8a3870243d.tar.bz2 itools-6d649237a4dae8cc6a1537902c1cfd8a3870243d.zip |
Fix it_dbi being used with it::map/iterator_to_array
-rw-r--r-- | it_dbi.class | 2 | ||||
-rwxr-xr-x | test/it_dbi.t | 4 |
2 files changed, 5 insertions, 1 deletions
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'); |