mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-07-07 17:04:59 +00:00
Mysql: Add SRID
column option (#1852)
This commit is contained in:
parent
05d7ffb1d5
commit
bf2b72fbe0
5 changed files with 21 additions and 0 deletions
|
@ -1758,6 +1758,13 @@ pub enum ColumnOption {
|
|||
/// ```
|
||||
/// [Snowflake]: https://docs.snowflake.com/en/sql-reference/sql/create-table
|
||||
Tags(TagsColumnOption),
|
||||
/// MySQL specific: Spatial reference identifier
|
||||
/// Syntax:
|
||||
/// ```sql
|
||||
/// CREATE TABLE geom (g GEOMETRY NOT NULL SRID 4326);
|
||||
/// ```
|
||||
/// [MySQL]: https://dev.mysql.com/doc/refman/8.4/en/creating-spatial-indexes.html
|
||||
Srid(Box<Expr>),
|
||||
}
|
||||
|
||||
impl fmt::Display for ColumnOption {
|
||||
|
@ -1873,6 +1880,9 @@ impl fmt::Display for ColumnOption {
|
|||
Tags(tags) => {
|
||||
write!(f, "{tags}")
|
||||
}
|
||||
Srid(srid) => {
|
||||
write!(f, "SRID {srid}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -871,6 +871,7 @@ impl Spanned for ColumnOption {
|
|||
ColumnOption::OnConflict(..) => Span::empty(),
|
||||
ColumnOption::Policy(..) => Span::empty(),
|
||||
ColumnOption::Tags(..) => Span::empty(),
|
||||
ColumnOption::Srid(..) => Span::empty(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -844,6 +844,7 @@ define_keywords!(
|
|||
SQLSTATE,
|
||||
SQLWARNING,
|
||||
SQRT,
|
||||
SRID,
|
||||
STABLE,
|
||||
STAGE,
|
||||
START,
|
||||
|
|
|
@ -7754,6 +7754,10 @@ impl<'a> Parser<'a> {
|
|||
&& dialect_of!(self is MySqlDialect | SQLiteDialect | DuckDbDialect | GenericDialect)
|
||||
{
|
||||
self.parse_optional_column_option_as()
|
||||
} else if self.parse_keyword(Keyword::SRID)
|
||||
&& dialect_of!(self is MySqlDialect | GenericDialect)
|
||||
{
|
||||
Ok(Some(ColumnOption::Srid(Box::new(self.parse_expr()?))))
|
||||
} else if self.parse_keyword(Keyword::IDENTITY)
|
||||
&& dialect_of!(self is MsSqlDialect | GenericDialect)
|
||||
{
|
||||
|
|
|
@ -3745,6 +3745,11 @@ fn parse_begin_without_transaction() {
|
|||
mysql().verified_stmt("BEGIN");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_geometric_types_srid_option() {
|
||||
mysql_and_generic().verified_stmt("CREATE TABLE t (a geometry SRID 4326)");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_double_precision() {
|
||||
mysql().verified_stmt("CREATE TABLE foo (bar DOUBLE)");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue