Skip to content
This repository was archived by the owner on Jun 2, 2025. It is now read-only.

Commit 698dd2f

Browse files
committed
Clean up and update inline docs
1 parent a6d5c38 commit 698dd2f

File tree

2 files changed

+14
-21
lines changed

2 files changed

+14
-21
lines changed

tests/WP_SQLite_Translator_Tests.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,20 +1252,19 @@ public function testColumnWithOnUpdate() {
12521252
$this->assertNull( $result[0]->updated_at );
12531253
}
12541254

1255-
public function testTimestampColumnNamedTimestamp() {
1255+
public function testTypeKeywordsAsKeyNames() {
12561256
// CREATE TABLE with ON UPDATE
12571257
$this->assertQuery(
1258-
"CREATE TABLE `_tmp_table` (
1258+
'CREATE TABLE `_tmp_table` (
12591259
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
12601260
`timestamp` datetime NOT NULL,
12611261
`numeric` int(11) NOT NULL,
12621262
PRIMARY KEY (`id`),
1263-
KEY timestamp (timestamp),
1263+
KEY `timestamp` (`timestamp`),
12641264
KEY numeric (numeric)
1265-
);"
1265+
);'
12661266
);
12671267
$results = $this->assertQuery( 'DESCRIBE _tmp_table;' );
1268-
var_dump( $results );
12691268
$this->assertEquals(
12701269
array(
12711270
(object) array(

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

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,27 +1010,21 @@ private function parse_create_table() {
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-
* instead we'll check whether the second non-whitespace
1017-
* token is a data type.
10181013
*/
1019-
$second_token = $this->rewriter->peek_nth( 2 );
10201014
$current_token = $this->rewriter->peek();
1015+
$second_token = $this->rewriter->peek_nth( 2 );
10211016

1022-
if ( $second_token->matches(
1023-
WP_SQLite_Token::TYPE_KEYWORD,
1024-
WP_SQLite_Token::FLAG_KEYWORD_DATA_TYPE
1025-
) && !$current_token->matches(
1026-
WP_SQLite_Token::TYPE_KEYWORD,
1027-
WP_SQLite_Token::FLAG_KEYWORD_RESERVED,
1028-
array( 'KEY' )
1029-
) ) {
1030-
echo 'field';
1017+
if (
1018+
$second_token->matches(
1019+
WP_SQLite_Token::TYPE_KEYWORD,
1020+
WP_SQLite_Token::FLAG_KEYWORD_DATA_TYPE
1021+
) && ! $current_token->matches(
1022+
WP_SQLite_Token::TYPE_KEYWORD,
1023+
WP_SQLite_Token::FLAG_KEYWORD_RESERVED,
1024+
)
1025+
) {
10311026
$result->fields[] = $this->parse_mysql_create_table_field();
10321027
} else {
1033-
echo 'constraint';
10341028
$result->constraints[] = $this->parse_mysql_create_table_constraint();
10351029
}
10361030

0 commit comments

Comments
 (0)