Skip to content

Commit 14f98b0

Browse files
committed
Split, cleanup, and reorganize the SQLite driver prototype
1 parent 9426969 commit 14f98b0

8 files changed

+290
-358
lines changed

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ phpcs.xml.dist export-ignore
77
phpunit.xml.dist export-ignore
88
/grammar-tools export-ignore
99
/tests export-ignore
10-
/wip export-ignore
1110
/wp-includes/mysql export-ignore
1211
/wp-includes/parser export-ignore
12+
/wp-includes/sqlite-ast export-ignore
1313
wp-includes/sqlite/class-wp-sqlite-crosscheck-db.php export-ignore

tests/tools/dump-sqlite-query.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
require_once __DIR__ . '/../../wp-includes/parser/class-wp-parser.php';
4+
require_once __DIR__ . '/../../wp-includes/parser/class-wp-parser-grammar.php';
5+
require_once __DIR__ . '/../../wp-includes/parser/class-wp-parser-node.php';
6+
require_once __DIR__ . '/../../wp-includes/mysql/class-wp-mysql-lexer.php';
7+
require_once __DIR__ . '/../../wp-includes/mysql/class-wp-mysql-token.php';
8+
require_once __DIR__ . '/../../wp-includes/mysql/class-wp-mysql-parser.php';
9+
require_once __DIR__ . '/../../wp-includes/sqlite-ast/class-wp-sqlite-expression.php';
10+
require_once __DIR__ . '/../../wp-includes/sqlite-ast/class-wp-sqlite-driver.php';
11+
require_once __DIR__ . '/../../wp-includes/sqlite-ast/class-wp-sqlite-token-factory.php';
12+
require_once __DIR__ . '/../../wp-includes/sqlite-ast/class-wp-sqlite-token.php';
13+
require_once __DIR__ . '/../../wp-includes/sqlite-ast/class-wp-sqlite-query-builder.php';
14+
15+
$grammar_data = include __DIR__ . '/../../wp-includes/mysql/mysql-grammar.php';
16+
$grammar = new WP_Parser_Grammar( $grammar_data );
17+
$driver = new WP_SQLite_Driver( $grammar );
18+
19+
$query = "SELECT * FROM t1 LEFT JOIN t2 ON t1.id = t2.t1_id WHERE t1.name = 'abc'";
20+
21+
echo $driver->run_query( $query );

wp-includes/mysql/class-wp-mysql-token.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ public function get_name() {
2929
return WP_MySQL_Lexer::get_token_name( $this->type );
3030
}
3131

32+
public function extract_value() {
33+
return $this->get_text();
34+
}
35+
3236
public function __toString() {
3337
return $this->text . '<' . $this->type . ',' . $this->get_name() . '>';
3438
}

0 commit comments

Comments
 (0)