From 38f1b9eee7e8ef78580639ce3081bf231919f52b Mon Sep 17 00:00:00 2001 From: Drew Foehn Date: Fri, 14 Oct 2011 11:29:06 -0400 Subject: [PATCH 1/3] modified: dbo_sqlite3.php modified dbo_sqlite3.php to allow for UUID PK --- models/datasources/dbo/dbo_sqlite3.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/models/datasources/dbo/dbo_sqlite3.php b/models/datasources/dbo/dbo_sqlite3.php index 7d48ee3..493fad0 100755 --- a/models/datasources/dbo/dbo_sqlite3.php +++ b/models/datasources/dbo/dbo_sqlite3.php @@ -73,7 +73,7 @@ class DboSqlite3 extends DboSource { * @access public */ var $columns = array( - 'primary_key' => array('name' => 'integer primary key autoincrement'), + 'primary_key' => array('name' => 'primary key'), 'string' => array('name' => 'varchar', 'limit' => '255'), 'text' => array('name' => 'text'), 'integer' => array('name' => 'integer', 'limit' => null, 'formatter' => 'intval'), @@ -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); From 7faa16a0ed23ba77b46ac0ac8b0d8afab4177b6e Mon Sep 17 00:00:00 2001 From: Drew Foehn Date: Fri, 14 Oct 2011 19:48:18 -0400 Subject: [PATCH 2/3] modified: dbo/dbo_sqlite3.php sqlite_sequence table shows up when listing sources and breaks function describe() --- models/datasources/dbo/dbo_sqlite3.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/datasources/dbo/dbo_sqlite3.php b/models/datasources/dbo/dbo_sqlite3.php index 493fad0..80c846f 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(); From 2e35009214c47eecdca1faab139286defbf963d2 Mon Sep 17 00:00:00 2001 From: Drew Foehn Date: Sat, 5 Nov 2011 19:32:31 -0400 Subject: [PATCH 3/3] modified: models/datasources/dbo/dbo_sqlite3.php Fixed default table type so primary key is integer type with autoincrement --- models/datasources/dbo/dbo_sqlite3.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/datasources/dbo/dbo_sqlite3.php b/models/datasources/dbo/dbo_sqlite3.php index 80c846f..bae295a 100755 --- a/models/datasources/dbo/dbo_sqlite3.php +++ b/models/datasources/dbo/dbo_sqlite3.php @@ -73,7 +73,7 @@ class DboSqlite3 extends DboSource { * @access public */ var $columns = array( - 'primary_key' => array('name' => 'primary key'), + 'primary_key' => array('name' => 'integer primary key autoincrement'), 'string' => array('name' => 'varchar', 'limit' => '255'), 'text' => array('name' => 'text'), 'integer' => array('name' => 'integer', 'limit' => null, 'formatter' => 'intval'),