Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Result#to_a raises IndexError #9

Open
pilcrow opened this issue Jun 5, 2013 · 0 comments
Open

Result#to_a raises IndexError #9

pilcrow opened this issue Jun 5, 2013 · 0 comments
Assignees

Comments

@pilcrow
Copy link
Member

pilcrow commented Jun 5, 2013

I believe the fix is that pg::Cursor#next_row should first return if last_row? before doing anything else.

$:» cat x.rb
#!/usr/bin/env ruby

require 'rdbi'
require 'rdbi-driver-postgresql'

puts 'ruby ' + RUBY_VERSION
Gem.loaded_specs.each do |name, gem|
  puts name + ' ' + gem.version.to_s
end
puts

conn_args = { :database => ARGV.shift,
                  :user => ARGV.shift,
              :password => ARGV.shift }

RDBI.connect(:PostgreSQL, conn_args) do |dbh|
  res = dbh.execute("SELECT true");
  puts res.to_a
end

$:» ruby  x.rb postgres me me
ruby 2.0.0
epoxy 0.3.1
typelib 0.1.0
rdbi 1.1.0
bigdecimal 1.2.0
pg 0.9.0
methlab 0.1.0
rdbi-driver-postgresql 0.9.1

/home/me/.gem/ruby/2.0.0/gems/rdbi-driver-postgresql-0.9.1/lib/rdbi/driver/postgresql.rb:148:in `[]': Index 1 is out of range (IndexError)
        from /home/me/.gem/ruby/2.0.0/gems/rdbi-driver-postgresql-0.9.1/lib/rdbi/driver/postgresql.rb:148:in `next_row'
        from /home/me/.gem/ruby/2.0.0/gems/rdbi-1.1.0/lib/rdbi/result.rb:249:in `fetch'
        from /home/me/.gem/ruby/2.0.0/gems/rdbi-1.1.0/lib/rdbi/result.rb:129:in `each'
        from x.rb:18:in `to_a'
        from x.rb:18:in `block in <main>'
        from /home/me/.gem/ruby/2.0.0/gems/rdbi-1.1.0/lib/rdbi.rb:39:in `connect'
        from x.rb:16:in `<main>'
@ghost ghost assigned Pistos Jan 4, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants