@@ -16,6 +16,9 @@ class SQLite_Command extends WP_CLI_Command {
1616 * <file>
1717 * : The name of the SQL file to import. If '-', then reads from STDIN. If omitted, it will look for '{dbname}.sql'.
1818 *
19+ * [--enable-ast-driver]
20+ * : Enables new AST driver for full MySQL compatibility.
21+ *
1922 * ## EXAMPLES
2023 * # Import the database from a file
2124 * $ wp sqlite import wordpress_dbase.sql
@@ -24,6 +27,13 @@ class SQLite_Command extends WP_CLI_Command {
2427 * @when after_wp_config_load
2528 */
2629 public function import ( $ args , $ assoc_args ) {
30+ $ enable_ast_driver = isset ( $ assoc_args ['enable-ast-driver ' ] );
31+
32+ if ( $ enable_ast_driver ) {
33+ if ( ! defined ( 'WP_SQLITE_AST_DRIVER ' ) || ! WP_SQLITE_AST_DRIVER ) {
34+ define ( 'WP_SQLITE_AST_DRIVER ' , true );
35+ }
36+ }
2737
2838 if ( empty ( $ args [0 ] ) ) {
2939 WP_CLI ::error ( 'Please provide a file to import. ' );
@@ -52,6 +62,9 @@ public function import( $args, $assoc_args ) {
5262 * [--porcelain]
5363 * : Output filename for the exported database.
5464 *
65+ * [--enable-ast-driver]
66+ * : Enables new AST driver for full MySQL compatibility.
67+ *
5568 * ## EXAMPLES
5669 * # Export the database to a file
5770 * $ wp sqlite export wordpress_dbase.sql
@@ -75,11 +88,19 @@ public function import( $args, $assoc_args ) {
7588 * @when after_wp_config_load
7689 */
7790 public function export ( $ args , $ assoc_args ) {
78- $ is_porcelain = isset ( $ assoc_args ['porcelain ' ] );
91+ $ is_porcelain = isset ( $ assoc_args ['porcelain ' ] );
92+ $ enable_ast_driver = isset ( $ assoc_args ['enable-ast-driver ' ] );
93+
94+ if ( $ enable_ast_driver ) {
95+ if ( ! defined ( 'WP_SQLITE_AST_DRIVER ' ) || ! WP_SQLITE_AST_DRIVER ) {
96+ define ( 'WP_SQLITE_AST_DRIVER ' , true );
97+ }
98+ }
7999
80100 if ( ! $ is_porcelain ) {
81101 WP_CLI ::success ( 'Exporting database... ' );
82102 }
103+
83104 $ export = new Export ();
84105
85106 if ( ! empty ( $ args [0 ] ) ) {
@@ -111,6 +132,9 @@ public function export( $args, $assoc_args ) {
111132 * - csv
112133 * ---
113134 *
135+ * [--enable-ast-driver]
136+ * : Enables new AST driver for full MySQL compatibility.
137+ *
114138 * ## EXAMPLES
115139 *
116140 * # List all tables in the database
@@ -131,6 +155,14 @@ public function export( $args, $assoc_args ) {
131155 * @when before_wp_load
132156 */
133157 public function tables ( $ args , $ assoc_args ) {
158+ $ enable_ast_driver = isset ( $ assoc_args ['enable-ast-driver ' ] );
159+
160+ if ( $ enable_ast_driver ) {
161+ if ( ! defined ( 'WP_SQLITE_AST_DRIVER ' ) || ! WP_SQLITE_AST_DRIVER ) {
162+ define ( 'WP_SQLITE_AST_DRIVER ' , true );
163+ }
164+ }
165+
134166 $ tables = new Tables ();
135167 $ tables ->run ( $ assoc_args );
136168 }
0 commit comments