Index: ddl/sqlite_sql_generator.php =================================================================== RCS file: /cvsroot/moodle/moodle/lib/ddl/sqlite_sql_generator.php,v retrieving revision 1.1 diff -u -r1.1 sqlite_sql_generator.php --- ddl/sqlite_sql_generator.php 22 Jun 2008 21:35:07 -0000 1.1 +++ ddl/sqlite_sql_generator.php 29 Jun 2008 21:18:55 -0000 @@ -49,7 +49,7 @@ public $sequence_only = true; //To avoid to output the rest of the field specs, leaving only the name and the sequence_name publiciable public $sequence_extra_code = false; //Does the generator need to add extra code to generate the sequence fields - public $sequence_name = 'INTEGER PRIMARY KEY AUTOINCREMENT'; //Particular name for inline sequences in this generator + public $sequence_name = 'INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL'; //Particular name for inline sequences in this generator public $unsigned_allowed = false; // To define in the generator must handle unsigned information public $enum_extra_code = false; //Does the generator need to add extra code to generate code for the enums in the table Index: dml/sqlite3_pdo_moodle_database.php =================================================================== RCS file: /cvsroot/moodle/moodle/lib/dml/sqlite3_pdo_moodle_database.php,v retrieving revision 1.2 diff -u -r1.2 sqlite3_pdo_moodle_database.php --- dml/sqlite3_pdo_moodle_database.php 22 Jun 2008 22:05:59 -0000 1.2 +++ dml/sqlite3_pdo_moodle_database.php 30 Jun 2008 06:45:50 -0000 @@ -110,7 +110,7 @@ */ public function get_tables() { $tables = array(); - $sql = 'SELECT name FROM sqlite_master WHERE type="table"'; + $sql = 'SELECT name FROM sqlite_master WHERE type="table" ORDER BY name'; if($this->debug) { $this->debug_query($sql); } @@ -132,13 +132,14 @@ */ public function get_indexes($table) { $indexes = array(); - $sql = 'SELECT * FROM sqlite_master WHERE type="index" AND tbl_name="'. $this->prefix . $table . '"'; + $sql = 'PRAGMA index_list('. $this->prefix . $table . ')'; if($this->debug) { $this->debug_query($sql); } $rsindexes = $this->pdb->query($sql); foreach($rsindexes as $index) { - $index = strtolower($index['name']); + $unique = (boolean)$index['unique']; + $index = $index['name']; $sql = 'PRAGMA index_info("' . $index . '")'; if($this->debug) { $this->debug_query($sql); @@ -149,6 +150,7 @@ $columns[] = strtolower($row['name']); } $index = strtolower($index); + $indexes[$index]['unique'] = $unique; $indexes[$index]['columns'] = $columns; } return $indexes; @@ -188,6 +190,9 @@ 'primary_key' => (boolean)$row['pk'], 'has_default' => !is_null($row['dflt_value']), 'default_value' => $row['dflt_value'], + 'auto_increment' => false, + 'binary' => false, + //'unsigned' => false, ); $type = explode('(', $row['type']); $columninfo['type'] = strtolower($type[0]); @@ -204,6 +209,7 @@ case 'int': // int integer if($columninfo['primary_key'] && preg_match('/' . $columninfo['name'] . '\W*integer\W*primary\W*key\W*autoincrement/im', $createsql)) { $columninfo['meta_type'] = 'R'; + $columninfo['auto_increment'] = true; } else { $columninfo['meta_type'] = 'I'; } @@ -225,11 +231,13 @@ case 'blo': // blob case 'non': // none $columninfo['meta_type'] = 'B'; + $columninfo['binary'] = true; break; case 'boo': // boolean case 'bit': // bit case 'log': // logical $columninfo['meta_type'] = 'L'; + $columninfo['max_length'] = 1; break; case 'tim': // timestamp $columninfo['meta_type'] = 'T'; @@ -238,7 +246,6 @@ $columninfo['meta_type'] = 'D'; break; } - $columns[$columninfo['name']] = new database_column_info($columninfo); }