@@ -1013,15 +1013,25 @@ private function parse_create_table() {
10131013 *
10141014 * Lexer does not seem to reliably understand whether the
10151015 * 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.
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.
10181022 */
1019- $ second_token = $ this ->rewriter ->peek_nth ( 2 );
1023+ $ current_token = $ this ->rewriter ->peek ();
1024+ $ second_token = $ this ->rewriter ->peek_nth ( 2 );
10201025
1021- if ( $ second_token ->matches (
1022- WP_SQLite_Token::TYPE_KEYWORD ,
1023- WP_SQLite_Token::FLAG_KEYWORD_DATA_TYPE
1024- ) ) {
1026+ if (
1027+ $ second_token ->matches (
1028+ WP_SQLite_Token::TYPE_KEYWORD ,
1029+ WP_SQLite_Token::FLAG_KEYWORD_DATA_TYPE
1030+ ) && ! $ current_token ->matches (
1031+ WP_SQLite_Token::TYPE_KEYWORD ,
1032+ WP_SQLite_Token::FLAG_KEYWORD_RESERVED
1033+ )
1034+ ) {
10251035 $ result ->fields [] = $ this ->parse_mysql_create_table_field ();
10261036 } else {
10271037 $ result ->constraints [] = $ this ->parse_mysql_create_table_constraint ();
0 commit comments