--zYM0uCDKw75PZbzx Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On 02:39 Wed 16 Feb , Erik Veenstra wrote: > I have a problem when using SQLITE3. I think it's a bug in the > Ruby bindings, but I'm not quiet sure. > > Just run this script to regenerate the problem. > > gegroet, > Erik V. Thanks for the bug report, Erik. Must be something about announcing a new release that causes these to occur. I dunno. ;) The problem was that some columns do not have a type (like those that are the result of functions and so forth), which caused type translation to barf. At any rate, I've found and fixed the problem, but as I won't have time to repackage SQLite3/Ruby for at least a few days, I've attached a patch instead. Alternatively, you can grab the latest from svn: http://www.jamisbuck.org/svn/sqlite3-ruby Note that the fix does NOT result in typeless columns (like MAX(c1) in your example) to be translated to integers--sqlite does not give me any information about the type of those columns, and so they are not translated. - Jamis > > ---------------------------------------------------------------- > > require "rubygems" > > require_gem "sqlite3-ruby" > > dbfile dummy.db" > > File.delete(dbfile) if File.file?(dbfile) > > db QLite3::Database.new(dbfile) > > db.type_translation rue # This is causing the problem. > > db.execute("CREATE TABLE t1 (c1 INTEGER)") > > db.execute("INSERT INTO t1 (c1) VALUES (1)") > db.execute("INSERT INTO t1 (c1) VALUES (2)") > db.execute("INSERT INTO t1 (c1) VALUES (3)") > > p db.execute("SELECT MAX(c1) FROM t1").shift.shift > > ---------------------------------------------------------------- > > > -- Jamis Buck jamis_buck / byu.edu http://jamis.jamisbuck.org ------------------------------ "I am Victor of Borge. You will be assimil-nine-ed." --zYM0uCDKw75PZbzx Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="typeless-columns.patch" Index: sqlite3/translator.rb --- sqlite3/translator.rb (revision 18) +++ sqlite3/translator.rb (working copy) @@ -81,6 +81,7 @@ # A convenience method for working with type names. This returns the "base" # type name, without any parenthetical data. def type_name( type ) + return "" if type.nil? type 1 if type /^(.*?)\(/ type.upcase end --zYM0uCDKw75PZbzx--