feat: add FULLTEXT option on create table for MySQL and Generic dialects (#702)

This commit is contained in:
Augusto Fotino 2022-11-11 18:03:39 -03:00 committed by GitHub
parent 87b4a168cb
commit cdf4447065
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 161 additions and 6 deletions

View file

@ -3085,6 +3085,38 @@ impl<'a> Parser<'a> {
columns,
}))
}
Token::Word(w)
if (w.keyword == Keyword::FULLTEXT || w.keyword == Keyword::SPATIAL)
&& dialect_of!(self is GenericDialect | MySqlDialect) =>
{
if let Some(name) = name {
return self.expected(
"FULLTEXT or SPATIAL option without constraint name",
Token::make_keyword(&name.to_string()),
);
}
let fulltext = w.keyword == Keyword::FULLTEXT;
let index_type_display = if self.parse_keyword(Keyword::KEY) {
KeyOrIndexDisplay::Key
} else if self.parse_keyword(Keyword::INDEX) {
KeyOrIndexDisplay::Index
} else {
KeyOrIndexDisplay::None
};
let opt_index_name = self.maybe_parse(|parser| parser.parse_identifier());
let columns = self.parse_parenthesized_column_list(Mandatory)?;
Ok(Some(TableConstraint::FulltextOrSpatial {
fulltext,
index_type_display,
opt_index_name,
columns,
}))
}
unexpected => {
if name.is_some() {
self.expected("PRIMARY, UNIQUE, FOREIGN, or CHECK", unexpected)