Skip to content

Commit bf3caee

Browse files
committed
fix(postgres): clarify peek guard rationale and cover SPATIAL index
1 parent 457cd2c commit bf3caee

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

src/parser/mod.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9810,10 +9810,9 @@ impl<'a> Parser<'a> {
98109810
None
98119811
};
98129812

9813-
// FULLTEXT and SPATIAL are MySQL-specific table constraint keywords. For
9814-
// dialects that don't support them (e.g. PostgreSQL) they are valid
9815-
// identifiers and must not be consumed here — the caller will parse them
9816-
// as column names instead.
9813+
// Peek instead of consuming: FULLTEXT/SPATIAL are only table constraints in
9814+
// MySQL/Generic, so consuming them before confirming the dialect would break
9815+
// the column-name fallback in other dialects (e.g. PostgreSQL).
98179816
if name.is_none()
98189817
&& self
98199818
.peek_one_of_keywords(&[Keyword::FULLTEXT, Keyword::SPATIAL])

tests/sqlparser_postgres.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7129,6 +7129,8 @@ fn parse_fulltext_as_column_name() {
71297129
pg().verified_stmt("CREATE TABLE geo (spatial TEXT NOT NULL)");
71307130

71317131
pg().verified_stmt("CREATE INDEX film_fulltext_idx ON film USING GIST (fulltext)");
7132+
7133+
pg().verified_stmt("CREATE INDEX geo_spatial_idx ON geo USING GIST (spatial)");
71327134
}
71337135

71347136
#[test]

0 commit comments

Comments
 (0)