diff --git a/lib/sqlite3/database.rb b/lib/sqlite3/database.rb index 01519882..29c7341e 100644 --- a/lib/sqlite3/database.rb +++ b/lib/sqlite3/database.rb @@ -395,6 +395,9 @@ def step( *args ) def finalize super(@ctx) + result = @ctx.result + @ctx = FunctionProxy.new + result end }) proxy.ctx = FunctionProxy.new diff --git a/test/test_integration.rb b/test/test_integration.rb index 5f707aff..9bd3c3a8 100644 --- a/test/test_integration.rb +++ b/test/test_integration.rb @@ -499,6 +499,10 @@ def test_create_aggregate_without_block value = @db.get_first_value( "select accumulate(a) from foo" ) assert_equal 6, value + + # calling #get_first_value twice don't add up to the latest result + value = @db.get_first_value( "select accumulate(a) from foo" ) + assert_equal 6, value end def test_create_aggregate_with_block