Skip to content

Commit

Permalink
Fix bug where Array was not expanded in Statement#execute
Browse files Browse the repository at this point in the history
  • Loading branch information
copiousfreetime committed Aug 1, 2009
1 parent 9d07960 commit 14d1625
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 2 deletions.
14 changes: 13 additions & 1 deletion HISTORY
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
= Amalgalite Changelog
== Version 0.10.2

=== Bug Fixes

* Statement#execute was not expanding an Array passed in to the positional
#bind parameters.

== Version 0.10.1 - 2009-08-01

=== Enhancements

* Add version subdirectory for extension on all platforms for building locally
on gem install.
* Small documentation change for Amalgalite::Database#new
* Add gem for x86-ming32 platform
* Add specs to validate the R*Tree index is compiled correctly

=== Bug Fixes

* Small documentation change for Amalgalite::Database#new

== Version 0.10.0 - 2009-06-28

=== Enhancements
Expand Down
1 change: 1 addition & 0 deletions TODO.taskpaper
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Next Release:
- On execute, if an array is passed in, should it be auto exploaded?
- type conversion for manifest typing? how to allow it through?
- table name and column name in a type map?

Expand Down
2 changes: 2 additions & 0 deletions lib/amalgalite/statement.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ def bind( *params )

if params.first.instance_of?( Hash ) then
bind_named_parameters( params.first )
elsif params.first.instance_of?( Array ) then
bind_positional_parameters( *params )
else
bind_positional_parameters( params )
end
Expand Down
2 changes: 1 addition & 1 deletion lib/amalgalite/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module Version

MAJOR = 0
MINOR = 10
BUILD = 1
BUILD = 2

#
# return the Version as an array of MAJOR, MINOR, BUILD
Expand Down
20 changes: 20 additions & 0 deletions spec/statement_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,26 @@
c.should eql(20)
end

it "expands an array when binding parameters" do
@db.execute(" CREATE TABLE t(x,y); ")
values = {}
@db.prepare( "INSERT INTO t( x, y ) VALUES( ?, ? )") do |stmt|
20.times do |x|
y = rand( x )
a = [ x, y ]
stmt.execute( a )
values[x] = y
end
end
c = 0
@db.execute("SELECT * from t") do |row|
c += 1
values[ row['x'] ].should eql(row['y'])
end
c.should eql(20)

end

it "binds a integer variable correctly" do
@iso_db.prepare("SELECT * FROM country WHERE id = ? ORDER BY name ") do |stmt|
all_rows = stmt.execute( 891 )
Expand Down

0 comments on commit 14d1625

Please sign in to comment.