ruby-sqlite 2.2.3 bug

Discussion in 'Ruby' started by Jon A. Lambert, Mar 17, 2006.

  1. This is using sqlite-ruby (2.2.3)

    -----------------------
    require 'sqlite'
    require 'pp'

    class Foo
    end
    db = SQLite::Database.open("test.sqlite")
    begin
    db.execute("drop table test;")
    rescue
    end
    db.execute("create table test (id integer primary key, data object);")
    db.type_translation = true
    db.translator.add_translator("object") {|type, value|
    db.class.decode value
    }
    db.execute("insert into test values (1, ?);", db.class.encode(Foo.new))
    db.execute("select * from test;") do |row|
    pp row
    end
    #db.type_translation = false <== uncomment to make work
    pp db.execute("pragma table_info(test)") <======= bug here
    db.table_info("test") do |row| <===== and here
    pp row
    end
    ----------------------

    [1, #<Foo:0x2c35ee0>]
    C:/apps/ruby/lib/ruby/gems/1.8/gems/sqlite-ruby-2.2.3-mswin32/lib/sqlite/translator.rb:85:in
    `type_name': undefined method `upcase' for nil:NilClass (NoMethodError)
    from
    C:/apps/ruby/lib/ruby/gems/1.8/gems/sqlite-ruby-2.2.3-mswin32/lib/sqlite/translator.rb:77:in
    `translate'
    from
    C:/apps/ruby/lib/ruby/gems/1.8/gems/sqlite-ruby-2.2.3-mswin32/lib/sqlite/resultset.rb:136:in
    `next'
    from
    C:/apps/ruby/lib/ruby/gems/1.8/gems/sqlite-ruby-2.2.3-mswin32/lib/sqlite/resultset.rb:135:in
    `next'
    from
    C:/apps/ruby/lib/ruby/gems/1.8/gems/sqlite-ruby-2.2.3-mswin32/lib/sqlite/resultset.rb:161:in
    `each'
    from
    C:/apps/ruby/lib/ruby/gems/1.8/gems/sqlite-ruby-2.2.3-mswin32/lib/sqlite/database.rb:199:in
    `execute'
    from C:/work/teensymud/trunk/testsql.rb:21

    Switching type_translation off allows pragma to work.

    Also example in documentation, shows 'db.decode' instead of
    'db.class.decode'

    --
    J. Lambert
    Jon A. Lambert, Mar 17, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. why the lucky stiff

    A Quick Guide to SQLite and Ruby

    why the lucky stiff, Jul 3, 2003, in forum: Ruby
    Replies:
    7
    Views:
    152
    Josef 'Jupp' Schugt
    Jul 3, 2003
  2. Jens Wessling

    SQLite/Ruby on Windows

    Jens Wessling, Apr 19, 2004, in forum: Ruby
    Replies:
    2
    Views:
    92
    Jim Moy
    Apr 20, 2004
  3. Jamis Buck

    [ANN] SQLite/Ruby 1.1

    Jamis Buck, May 11, 2004, in forum: Ruby
    Replies:
    0
    Views:
    93
    Jamis Buck
    May 11, 2004
  4. Carl Youngblood
    Replies:
    1
    Views:
    222
    Carl Youngblood
    Apr 9, 2005
  5. Replies:
    4
    Views:
    344
Loading...

Share This Page