Index: /branches/release-41/lib/MT/ObjectDriver/DDL/SQLite.pm
===================================================================
--- /branches/release-41/lib/MT/ObjectDriver/DDL/SQLite.pm (revision 2700)
+++ /branches/release-41/lib/MT/ObjectDriver/DDL/SQLite.pm (revision 2705)
@@ -90,6 +90,4 @@
     my $table_name = $class->table_name;
     my $field_prefix = $class->datasource;
-    my $props = $class->properties;
-    my $obj_defs = $class->column_defs;
 
     return undef unless $dbh;
@@ -98,22 +96,14 @@
     # may not actually exist (in which case, the return value is undef,
     # signalling an nonexistent table to the caller).
-    local $dbh->{RaiseError} = 0;
-    my $sth = $dbh->prepare('SELECT * FROM ' . $table_name . ' LIMIT 1')
+    local $dbh->{RaiseError} = 1;
+    my $sth = $dbh->prepare('PRAGMA table_info("' . $table_name . '")')
         or return undef;
     $sth->execute or return undef;
-    my $fields = $sth->{'NUM_OF_FIELDS'};
-    my $coltypes = $sth->{'TYPE'};
-    my $name = $sth->{'NAME'};
-    my $null = $sth->{'NULLABLE'};
-    #my $skip_null_checks;
-    #if (!$null || !@$null) {
-    #    $skip_null_checks = 1;
-    #}
     my $defs = {};
-    foreach (my $col = 0; $col < $fields; $col++) {
-        my $colname = lc $name->[$col];
+    while (my $row = $sth->fetchrow_hashref) {
+        my $colname = lc $row->{name};
         $colname =~ s/^\Q$field_prefix\E_//i;
-        my $coltype = $ddl->db2type($coltypes->[$col]);
-        if ($coltypes->[$col] =~ m/\((\d+)\)/) {
+        my $coltype = $ddl->db2type($row->{type});
+        if ($row->{type} =~ m/\((\d+)\)/) {
             $defs->{$colname}{size} = $1;
         }
@@ -122,19 +112,16 @@
             $defs->{$colname}{key} = 1;
         }
-        if ( $coltype eq 'integer' && $defs->{$colname}{key} ) {
+        if ( ($coltype eq 'integer') && $row->{pk} ) {
             # with sqlite, integer primary keys auto increment. always.
+            $defs->{$colname}{key} = 1;
             $defs->{$colname}{auto} = 1;
         }
-        #if ($skip_null_checks) {
-        if ( exists $obj_defs->{$colname} ) {
-            $defs->{$colname}{not_null} = $obj_defs->{$colname}{not_null};
-        }
-        #} else {
-        #    if ( (defined $null->[$col]) && ($null->[$col] == 0) ) {
-        #        $defs->{$colname}{not_null} = 1;
-        #    }
-        #}
+        $defs->{$colname}{not_null} = 1
+            if $row->{notnull};
+        $defs->{$colname}{default} = $row->{dflt_value}
+            if defined $row->{dflt_value};
     }
     $sth->finish;
+    return undef unless %$defs;
     return $defs;
 }
@@ -153,9 +140,29 @@
     my $ddl = shift;
     my ($def) = @_;
+    return undef if !defined $def;
     my $type = (ref($def) eq 'HASH') ? $def->{type} : $def;
+    $type = $def->{type};
     if ($type eq 'string') {
-        $type = 'varchar(' . $def->{size} . ')';
-    }
-    return $type;
+        return 'varchar(' . $def->{size} . ')';
+    } elsif ($type eq 'smallint' ) {
+        return 'smallint';
+    } elsif ($type eq 'bigint' ) {
+        return 'bigint';
+    } elsif ($type eq 'boolean') {
+        return 'boolean';
+    } elsif ($type eq 'datetime') {
+        return 'datetime';
+    } elsif ($type eq 'timestamp') {
+        return 'timestamp';
+    } elsif ($type eq 'integer') {
+        return 'integer';
+    } elsif ($type eq 'blob') {
+        return 'blob';
+    } elsif ($type eq 'text') {
+        return 'text';
+    } elsif ($type eq 'float') {
+        return 'float';
+    }
+    Carp::croak("undefined type: ". $type);
 }
 
Index: /branches/release-41/t/ddl-tests.pl
===================================================================
--- /branches/release-41/t/ddl-tests.pl (revision 2571)
+++ /branches/release-41/t/ddl-tests.pl (revision 2705)
@@ -112,6 +112,4 @@
     my $self = shift;
 
-    $self->init_testdb();
-
     my $driver    = MT::Object->dbi_driver;
     my $dbh       = $driver->rw_handle;
@@ -312,8 +310,14 @@
     ok($defs->{baz}, 'Ddltest::Fixable table has baz column after creation');
 
-    my $sql = $ddl_class->drop_column_sql('Ddltest::Fixable', 'baz');
-    ok($sql, 'Ddltest::Fixable can have column dropping sql');
-    my $res = $dbh->do($sql);
-    ok($res, 'Ddltest::Fixable could have its column dropped');
+    my $sql;
+    my $res;
+
+    SKIP: {
+        skip("Driver cannot drop columns", 2) unless $ddl_class->can_drop_column;
+        $sql = $ddl_class->drop_column_sql('Ddltest::Fixable', 'baz');
+        ok($sql, 'Ddltest::Fixable can have column dropping sql');
+        $res = $dbh->do($sql);
+        ok($res, 'Ddltest::Fixable could have its column dropped');
+    }
 
     {
@@ -327,5 +331,8 @@
 
     $defs = $ddl_class->column_defs('Ddltest::Fixable');
-    ok(!$defs->{baz},  'Ddltest::Fixable did indeed have a column dropped');
+    SKIP: {
+        skip("Driver cannot drop columns", 1) unless $ddl_class->can_drop_column;
+        ok(!$defs->{baz},  'Ddltest::Fixable did indeed have a column dropped');
+    }
     ok( $defs->{borf}, 'Ddltest::Fixable did indeed have a column added');
 
