summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJamis Buck <jamis@37signals.com>2005-02-05 18:24:44 +0000
committerJamis Buck <jamis@37signals.com>2005-02-05 18:24:44 +0000
commit4177b060cf5ef89f3f08661d8223dc2d487a3f45 (patch)
tree9abfe93d4f961e0833cd1279519c37c2dc963d28
parent7c6454770093d4cadd139af7c5c0223ed541b00b (diff)
downloadthird_party-sqlite3-ruby-4177b060cf5ef89f3f08661d8223dc2d487a3f45.tar.gz
third_party-sqlite3-ruby-4177b060cf5ef89f3f08661d8223dc2d487a3f45.tar.xz
third_party-sqlite3-ruby-4177b060cf5ef89f3f08661d8223dc2d487a3f45.zip
Version bump, and made it so that an array may be passed as the bind parameter and it will be flattened prior to binding. The native implementation of bind_text also does a to_s on its parameter now to prevent segfaults.
-rw-r--r--lib/sqlite3/driver/native/driver.rb2
-rw-r--r--lib/sqlite3/statement.rb2
-rw-r--r--lib/sqlite3/version.rb4
-rw-r--r--test/tc_integration.rb6
4 files changed, 10 insertions, 4 deletions
diff --git a/lib/sqlite3/driver/native/driver.rb b/lib/sqlite3/driver/native/driver.rb
index ee5e4a7..fce2f6d 100644
--- a/lib/sqlite3/driver/native/driver.rb
+++ b/lib/sqlite3/driver/native/driver.rb
@@ -92,7 +92,7 @@ module SQLite3 ; module Driver ; module Native
def bind_text( stmt, index, value, utf16=false )
API.send( ( utf16 ? :sqlite3_bind_text16 : :sqlite3_bind_text ),
- stmt, index, value )
+ stmt, index, value.to_s )
end
def column_name( stmt, index, utf16=false )
diff --git a/lib/sqlite3/statement.rb b/lib/sqlite3/statement.rb
index 8d2e3d5..bad70db 100644
--- a/lib/sqlite3/statement.rb
+++ b/lib/sqlite3/statement.rb
@@ -88,7 +88,7 @@ module SQLite3
# Statement#bind_params.
def bind_params( *bind_vars )
index = 1
- bind_vars.each do |var|
+ bind_vars.flatten.each do |var|
if Hash === var
var.each { |key, val| bind_param key, val }
else
diff --git a/lib/sqlite3/version.rb b/lib/sqlite3/version.rb
index 542cd75..0b3bf69 100644
--- a/lib/sqlite3/version.rb
+++ b/lib/sqlite3/version.rb
@@ -34,8 +34,8 @@ module SQLite3
module Version
- MAJOR = 0
- MINOR = 9
+ MAJOR = 1
+ MINOR = 0
TINY = 0
STRING = [ MAJOR, MINOR, TINY ].join( "." )
diff --git a/test/tc_integration.rb b/test/tc_integration.rb
index 2dd6016..948e833 100644
--- a/test/tc_integration.rb
+++ b/test/tc_integration.rb
@@ -587,6 +587,12 @@ module Integration
value = @db.get_first_value( "select multiply(a) from foo" )
assert_equal "6", value
end
+
+ define_method( "test_bind_array_parameter" ) do
+ result = @db.get_first_value( "select b from foo where a=? and b=?",
+ [ 1, "foo" ] )
+ assert_equal "foo", result
+ end
end
const_set( "TC_Database_#{driver}", test_case )