summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJamis Buck <jamis@37signals.com>2007-01-13 19:46:24 +0000
committerJamis Buck <jamis@37signals.com>2007-01-13 19:46:24 +0000
commita5730ff50de9392e880df698cf9c73af0a0fce9b (patch)
tree9f8c2305fa16292fcc3208d5a3264093161c535d
parent0e18b672c55c728834b565732939405eb4582c30 (diff)
downloadthird_party-sqlite3-ruby-a5730ff50de9392e880df698cf9c73af0a0fce9b.tar.gz
third_party-sqlite3-ruby-a5730ff50de9392e880df698cf9c73af0a0fce9b.tar.xz
third_party-sqlite3-ruby-a5730ff50de9392e880df698cf9c73af0a0fce9b.zip
Allow bignum values to be bound (thanks Timothy Wood, closes #3463)
-rw-r--r--lib/sqlite3/statement.rb2
-rw-r--r--test/tc_integration.rb11
2 files changed, 13 insertions, 0 deletions
diff --git a/lib/sqlite3/statement.rb b/lib/sqlite3/statement.rb
index 0de27f1..20de9ee 100644
--- a/lib/sqlite3/statement.rb
+++ b/lib/sqlite3/statement.rb
@@ -117,6 +117,8 @@ module SQLite3
must_be_open!
if Fixnum === param
case value
+ when Bignum then
+ @driver.bind_int64( @handle, param, value )
when Integer then
@driver.bind_int( @handle, param, value )
when Numeric then
diff --git a/test/tc_integration.rb b/test/tc_integration.rb
index e197006..8bb4c4a 100644
--- a/test/tc_integration.rb
+++ b/test/tc_integration.rb
@@ -743,6 +743,17 @@ module Integration
assert_equal 1, @stmt.execute!.length
end
+ define_method( "test_bind_param_with_various_types" ) do
+ @db.transaction do
+ @db.execute "create table all_types ( a integer primary key, b float, c string, d integer )"
+ @db.execute "insert into all_types ( b, c, d ) values ( 1.4, 'hello', 68719476735 )"
+ end
+
+ assert_equal 1, @db.execute( "select * from all_types where b = ?", 1.4 ).length
+ assert_equal 1, @db.execute( "select * from all_types where c = ?", 'hello').length
+ assert_equal 1, @db.execute( "select * from all_types where d = ?", 68719476735).length
+ end
+
define_method( "test_execute_no_bind_no_block" ) do
assert_instance_of SQLite3::ResultSet, @stmt.execute
end