Source: ruby-sqlite3
Version: 1.4.2-3
Severity: serious
Tags: patch

Hi,

SQLite3 3.37.0 and onwards changed its inner working. Now table column
data types are stored as a value and always returned as uppercase
text. This breaks your package as it relies on the old behavior, when
this was stored as text and returned in a case it was defined.
As I broke it, I've created a fix for you, patch is attached.

Sorry for the inconvenience,
Laszlo/GCS
Description: SQLite3 3.37.0+ use uppercase column tupe names
 Starting with SQLite3 3.37.0 it stores column type names as a value and
 always displayed in uppercase letters.
 Previously it stored type names as text with the same case as it was given. 
 This breaks testing where the column type is defined in lowercase and
 expects it to be given back as-is.
 Fix this with using type names in uppercase.
Author: Laszlo Boszormenyi (GCS) <g...@debian.org>
Forwarded: no
Last-Update: 2022-01-08

---

--- ruby-sqlite3-1.4.2.orig/test/test_database.rb
+++ ruby-sqlite3-1.4.2/test/test_database.rb
@@ -268,12 +268,12 @@ module SQLite3
 
     def test_table_info
       db = SQLite3::Database.new(':memory:', :results_as_hash => true)
-      db.execute("create table foo ( a integer primary key, b text )")
+      db.execute("create table foo ( a INTEGER primary key, b TEXT )")
       info = [{
         "name"       => "a",
         "pk"         => 1,
         "notnull"    => 0,
-        "type"       => "integer",
+        "type"       => "INTEGER",
         "dflt_value" => nil,
         "cid"        => 0
       },
@@ -281,7 +281,7 @@ module SQLite3
         "name"       => "b",
         "pk"         => 0,
         "notnull"    => 0,
-        "type"       => "text",
+        "type"       => "TEXT",
         "dflt_value" => nil,
         "cid"        => 1
       }]
--- ruby-sqlite3-1.4.2.orig/test/test_integration.rb
+++ ruby-sqlite3-1.4.2/test/test_integration.rb
@@ -34,11 +34,11 @@ class TC_Database_Integration < SQLite3:
 
   def test_table_info_without_defaults_for_version_3_3_8_and_higher
     @db.transaction do
-      @db.execute "create table no_defaults_test ( a integer default 1, b integer )"
+      @db.execute "create table no_defaults_test ( a INTEGER default 1, b INTEGER )"
       data = @db.table_info( "no_defaults_test" )
-      assert_equal({"name" => "a", "type" => "integer", "dflt_value" => "1", "notnull" => 0, "cid" => 0, "pk" => 0},
+      assert_equal({"name" => "a", "type" => "INTEGER", "dflt_value" => "1", "notnull" => 0, "cid" => 0, "pk" => 0},
         data[0])
-      assert_equal({"name" => "b", "type" => "integer", "dflt_value" => nil, "notnull" => 0, "cid" => 1, "pk" => 0},
+      assert_equal({"name" => "b", "type" => "INTEGER", "dflt_value" => nil, "notnull" => 0, "cid" => 1, "pk" => 0},
         data[1])
     end
   end
--- ruby-sqlite3-1.4.2.orig/test/test_integration_resultset.rb
+++ ruby-sqlite3-1.4.2/test/test_integration_resultset.rb
@@ -4,7 +4,7 @@ class TC_ResultSet < SQLite3::TestCase
   def setup
     @db = SQLite3::Database.new(":memory:")
     @db.transaction do
-      @db.execute "create table foo ( a integer primary key, b text )"
+      @db.execute "create table foo ( a INTEGER primary key, b TEXT )"
       @db.execute "insert into foo ( b ) values ( 'foo' )"
       @db.execute "insert into foo ( b ) values ( 'bar' )"
       @db.execute "insert into foo ( b ) values ( 'baz' )"
@@ -118,7 +118,7 @@ class TC_ResultSet < SQLite3::TestCase
   end
 
   def test_types
-    assert_equal [ "integer", "text" ], @result.types
+    assert_equal [ "INTEGER", "TEXT" ], @result.types
   end
 
   def test_columns

Reply via email to