diff --git a/test/connection_query_ng.rb b/test/connection_query_ng.rb new file mode 100644 index 0000000..b0af959 --- /dev/null +++ b/test/connection_query_ng.rb @@ -0,0 +1,27 @@ +# example1.rb +require 'duckdb' + +temp_file = "#{File.expand_path('.', __dir__)}/data.duckdb" +puts temp_file + +db = DuckDB::Database.open(temp_file) +con = db.connect + +con.query('CREATE TABLE test (id INTEGER)') +con.query('INSERT INTO test VALUES (?), (?)', 1, 2) + +con.close +db.close + +file_last_saved1 = File.mtime(temp_file) # DBクローズ直後にファイルの最終更新日時を取得 +i = 0 +while file_last_saved1 == File.mtime(temp_file) && i < 5000 + sleep 0.0001 + i += 1 +end +file_last_saved2 = File.mtime(temp_file) # しばらくしてからファイルの最終更新日時を取得 + +# なぜか file_last_saved1 と file_last_saved2 が異なる +p file_last_saved1 # => 2024-11-27 13:18:42.213986983 +0900 (1) +p file_last_saved2 # => 2024-11-27 13:18:42.643766951 +0900 (2) +File.delete(temp_file) diff --git a/test/duckdb_test/connection_query_test.rb b/test/duckdb_test/connection_query_test.rb new file mode 100644 index 0000000..16b5255 --- /dev/null +++ b/test/duckdb_test/connection_query_test.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +module DuckDBTest + class ConnectionQueryTest < Minitest::Test + def teardown + File.delete(@file) if File.exist?(@file) + end + + def test_prepared_statement_destroy_in_query + outputs = `ruby -Ilib test/connection_query_ng.rb #{@file}` + @file, before, after = outputs.split("\n") + assert_equal(before, after) + end + end +end