-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix PreparedStatement#destroy calling in Connection#query method.
- Loading branch information
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |