Skip to content

Commit 710c4be

Browse files
committed
Add param allowing to enable AST driver
1 parent b62649c commit 710c4be

2 files changed

Lines changed: 42 additions & 1 deletion

File tree

‎README.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ $ wp sqlite import <file>
2020
<file>
2121
The path to the MySQL compatible dump file to import. When passing `-` as the file argument, the SQL commands are read from standard input.
2222

23+
[--enable-ast-driver]
24+
Enables new AST driver for full MySQL compatibility.
25+
2326
### wp sqlite export
2427

2528
Exports an SQLite database to a MySQL compatible file.
@@ -42,6 +45,9 @@ $ wp sqlite export [<file>] [--tables=<tables>] [--exclude-tables] [--porcelain]
4245
[--porcelain]
4346
Output filename for the exported database.
4447

48+
[--enable-ast-driver]
49+
Enables new AST driver for full MySQL compatibility.
50+
4551
### wp sqlite tables
4652

4753
Lists the SQLite database tables.
@@ -61,6 +67,9 @@ $ wp sqlite tables [--format=<list|csv>]
6167
- csv
6268
---
6369

70+
[--enable-ast-driver]
71+
Enables new AST driver for full MySQL compatibility.
72+
6473
**EXAMPLES**
6574

6675
```

‎src/SQLite_Command.php‎

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)