Skip to content

Commit d3637f3

Browse files
committed
Update inline docs
1 parent ae0cd50 commit d3637f3

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

tests/WP_SQLite_Translator_Tests.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1253,7 +1253,7 @@ public function testColumnWithOnUpdate() {
12531253
}
12541254

12551255
public function testTypeKeywordsAsKeyNames() {
1256-
// CREATE TABLE with ON UPDATE
1256+
// CREATE TABLE with a data type as a key name
12571257
$this->assertQuery(
12581258
'CREATE TABLE `_tmp_table` (
12591259
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,

wp-includes/sqlite/class-wp-sqlite-translator.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1004,12 +1004,21 @@ private function parse_create_table() {
10041004
$this->rewriter->replace_all( array() );
10051005

10061006
/*
1007-
* Decide how to parse the current line. We expect either:
1007+
* Decide how to parse the current line. We ehttps://github.com/WordPress/sqlite-database-integration/blob/eba8ab5a92d95d332cdbcdf008c7328906027cc2/wp-includes/sqlite/class-wp-sqlite-translator.php#L1007xpect either:
10081008
*
10091009
* Field definition, e.g.:
10101010
* `my_field` varchar(255) NOT NULL DEFAULT 'foo'
10111011
* Constraint definition, e.g.:
10121012
* PRIMARY KEY (`my_field`)
1013+
*
1014+
* Lexer does not seem to reliably understand whether the
1015+
* first token is a field name or a reserved keyword, so
1016+
* alongside checking for the reserved keyword, we'll also
1017+
* check whether the second non-whitespace token is a data type.
1018+
*
1019+
* By checking for the reserved keyword, we can be sure that
1020+
* we're not parsing a constraint as a field when the
1021+
* constraint symbol matches a data type.
10131022
*/
10141023
$current_token = $this->rewriter->peek();
10151024
$second_token = $this->rewriter->peek_nth( 2 );

0 commit comments

Comments
 (0)