mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-03 13:58:15 +00:00
feat: add FULLTEXT option on create table for MySQL and Generic dialects (#702)
This commit is contained in:
parent
87b4a168cb
commit
cdf4447065
5 changed files with 161 additions and 6 deletions
|
@ -14,16 +14,15 @@
|
|||
//! Test SQL syntax specific to MySQL. The parser based on the generic dialect
|
||||
//! is also tested (on the inputs it can handle).
|
||||
|
||||
#[macro_use]
|
||||
mod test_utils;
|
||||
|
||||
use test_utils::*;
|
||||
|
||||
use sqlparser::ast::Expr;
|
||||
use sqlparser::ast::Value;
|
||||
use sqlparser::ast::*;
|
||||
use sqlparser::dialect::{GenericDialect, MySqlDialect};
|
||||
use sqlparser::tokenizer::Token;
|
||||
use test_utils::*;
|
||||
|
||||
#[macro_use]
|
||||
mod test_utils;
|
||||
|
||||
#[test]
|
||||
fn parse_identifiers() {
|
||||
|
@ -1129,6 +1128,48 @@ fn parse_create_table_with_index_definition() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_create_table_with_fulltext_definition() {
|
||||
mysql_and_generic().verified_stmt("CREATE TABLE tb (id INT, FULLTEXT (id))");
|
||||
|
||||
mysql_and_generic().verified_stmt("CREATE TABLE tb (id INT, FULLTEXT INDEX (id))");
|
||||
|
||||
mysql_and_generic().verified_stmt("CREATE TABLE tb (id INT, FULLTEXT KEY (id))");
|
||||
|
||||
mysql_and_generic().verified_stmt("CREATE TABLE tb (id INT, FULLTEXT potato (id))");
|
||||
|
||||
mysql_and_generic().verified_stmt("CREATE TABLE tb (id INT, FULLTEXT INDEX potato (id))");
|
||||
|
||||
mysql_and_generic().verified_stmt("CREATE TABLE tb (id INT, FULLTEXT KEY potato (id))");
|
||||
|
||||
mysql_and_generic()
|
||||
.verified_stmt("CREATE TABLE tb (c1 INT, c2 INT, FULLTEXT KEY potato (c1, c2))");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_create_table_with_spatial_definition() {
|
||||
mysql_and_generic().verified_stmt("CREATE TABLE tb (id INT, SPATIAL (id))");
|
||||
|
||||
mysql_and_generic().verified_stmt("CREATE TABLE tb (id INT, SPATIAL INDEX (id))");
|
||||
|
||||
mysql_and_generic().verified_stmt("CREATE TABLE tb (id INT, SPATIAL KEY (id))");
|
||||
|
||||
mysql_and_generic().verified_stmt("CREATE TABLE tb (id INT, SPATIAL potato (id))");
|
||||
|
||||
mysql_and_generic().verified_stmt("CREATE TABLE tb (id INT, SPATIAL INDEX potato (id))");
|
||||
|
||||
mysql_and_generic().verified_stmt("CREATE TABLE tb (id INT, SPATIAL KEY potato (id))");
|
||||
|
||||
mysql_and_generic()
|
||||
.verified_stmt("CREATE TABLE tb (c1 INT, c2 INT, SPATIAL KEY potato (c1, c2))");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic = "Expected FULLTEXT or SPATIAL option without constraint name, found: cons"]
|
||||
fn parse_create_table_with_fulltext_definition_should_not_accept_constraint_name() {
|
||||
mysql_and_generic().verified_stmt("CREATE TABLE tb (c1 INT, CONSTRAINT cons FULLTEXT (c1))");
|
||||
}
|
||||
|
||||
fn mysql() -> TestedDialects {
|
||||
TestedDialects {
|
||||
dialects: vec![Box::new(MySqlDialect {})],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue