Skip to content

Commit 185db71

Browse files
committed
Fix the parenthesis issue
1 parent 369aeed commit 185db71

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

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

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1149,7 +1149,28 @@ private function parse_mysql_create_table_field() {
11491149
WP_SQLite_Token::FLAG_KEYWORD_FUNCTION,
11501150
array( 'DEFAULT' )
11511151
) ) {
1152-
$result->default = $this->rewriter->consume()->token;
1152+
// Consume the next token (could be a value, opening paren, etc.)
1153+
$default_token = $this->rewriter->consume();
1154+
$result->default = $default_token->token;
1155+
1156+
// Check if the default value is wrapped in parentheses (for function calls like (now()))
1157+
if ( $default_token->matches( WP_SQLite_Token::TYPE_OPERATOR, null, array( '(' ) ) ) {
1158+
// Track parenthesis depth to consume the complete expression
1159+
$paren_depth = 1;
1160+
$default_value = '(';
1161+
1162+
while ( $paren_depth > 0 && ( $next_token = $this->rewriter->consume() ) ) {
1163+
$default_value .= $next_token->token;
1164+
1165+
if ( $next_token->matches( WP_SQLite_Token::TYPE_OPERATOR, null, array( '(' ) ) ) {
1166+
++$paren_depth;
1167+
} elseif ( $next_token->matches( WP_SQLite_Token::TYPE_OPERATOR, null, array( ')' ) ) ) {
1168+
--$paren_depth;
1169+
}
1170+
}
1171+
1172+
$result->default = $default_value;
1173+
}
11531174
continue;
11541175
}
11551176

0 commit comments

Comments
 (0)