@@ -494,6 +494,11 @@ public function get_insert_id() {
494494 * @return mixed Return value, depending on the query type.
495495 *
496496 * @throws WP_SQLite_Driver_Exception When the query execution fails.
497+ *
498+ * TODO:
499+ * The API of this function is not final.
500+ * We should also add support for parametrized queries.
501+ * See: https://github.com/Automattic/sqlite-database-integration/issues/7
497502 */
498503 public function query ( string $ query , $ fetch_mode = PDO ::FETCH_OBJ , ...$ fetch_mode_args ) {
499504 $ this ->flush ();
@@ -713,9 +718,17 @@ private function execute_mysql_query( WP_Parser_Node $node ): void {
713718 case 'createStatement ' :
714719 $ subtree = $ node ->get_first_child_node ();
715720 switch ( $ subtree ->rule_name ) {
721+ case 'createDatabase ' :
722+ /*
723+ * TODO:
724+ * This should probably be a no-op, in combination with
725+ * DROP DATABASE deleting the data file and recreating it.
726+ */
716727 case 'createTable ' :
717728 $ this ->execute_create_table_statement ( $ node );
718729 break ;
730+ case 'createIndex ' :
731+ // TODO: SQLite has a CREATE INDEX statement. We should support it.
719732 default :
720733 throw $ this ->new_not_supported_exception (
721734 sprintf (
@@ -1312,6 +1325,27 @@ private function execute_show_statement( WP_Parser_Node $node ): void {
13121325 * @param string $table_name The table name to show indexes for.
13131326 */
13141327 private function execute_show_index_statement ( string $ table_name ): void {
1328+ // TODO: FROM/IN (multiple)
1329+ // TODO: WHERE
1330+
1331+ /*
1332+ * TODO: Index naming.
1333+ *
1334+ * From the old driver:
1335+ *
1336+ * SQLite automatically assigns names to some indexes.
1337+ * However, dbDelta in WordPress expects the name to be
1338+ * the same as in the original CREATE TABLE. Let's
1339+ * translate the name back.
1340+ *
1341+ * The old driver does the two following conversions:
1342+ * 1)
1343+ * $mysql_key_name = substr( $mysql_key_name, strlen( 'sqlite_autoindex_' ) );
1344+ * $mysql_key_name = preg_replace( '/_[0-9]+$/', '', $mysql_key_name );
1345+ * 2)
1346+ * $mysql_key_name = substr( $mysql_key_name, strlen( "{$table_name}__" ) );
1347+ */
1348+
13151349 $ statistics_table = $ this ->information_schema_builder ->get_table_name ( 'statistics ' );
13161350 $ index_info = $ this ->execute_sqlite_query (
13171351 '
@@ -1474,6 +1508,7 @@ private function execute_show_tables_statement( WP_Parser_Node $node ): void {
14741508 * @throws PDOException When given table doesn't exist.
14751509 */
14761510 private function execute_show_columns_statement ( WP_Parser_Node $ node ): void {
1511+ // TODO: EXTENDED, FULL
14771512 $ table_name = $ this ->unquote_sqlite_identifier (
14781513 $ this ->translate ( $ node ->get_first_child_node ( 'tableRef ' ) )
14791514 );
0 commit comments