diff --git a/models/datasources/dbo/dbo_sqlite3.php b/models/datasources/dbo/dbo_sqlite3.php index 7d48ee3..bae295a 100755 --- a/models/datasources/dbo/dbo_sqlite3.php +++ b/models/datasources/dbo/dbo_sqlite3.php @@ -239,7 +239,7 @@ function listSources() { return $cache; } - $result = $this->fetchAll("SELECT name FROM sqlite_master WHERE type='table' ORDER BY name;", false); + $result = $this->fetchAll("SELECT name FROM sqlite_master WHERE type='table' AND name <> 'sqlite_sequence' ORDER BY name;", false); if (!$result || empty($result)) { return array(); @@ -280,12 +280,13 @@ function describe(&$model) { 'length' => $this->length($column[0]['type']) ); if($column[0]['pk'] == 1) { + $colLength = $this->length($column[0]['type']); $fields[$column[0]['name']] = array( 'type' => $fields[$column[0]['name']]['type'], 'null' => false, 'default' => $column[0]['dflt_value'], 'key' => $this->index['PRI'], - 'length' => 11 + 'length' => ($colLength != null) ? $colLength : 11 ); } } @@ -489,7 +490,7 @@ function column($real) { if (in_array($col, array('text', 'integer', 'float', 'boolean', 'timestamp', 'date', 'datetime', 'time'))) { return $col; } - if (strpos($col, 'varchar') !== false) { + if (strpos($col, 'char') !== false) { return 'string'; } if (in_array($col, array('blob', 'clob'))) { @@ -625,7 +626,7 @@ function buildColumn($column) { $real = $this->columns[$type]; $out = $this->name($name) . ' ' . $real['name']; - if (isset($column['key']) && $column['key'] == 'primary' && $type == 'integer') { + if (isset($column['key']) && $column['key'] == 'primary') { return $this->name($name) . ' ' . $this->columns['primary_key']['name']; } return parent::buildColumn($column);