File tree Expand file tree Collapse file tree 5 files changed +21
-0
lines changed Expand file tree Collapse file tree 5 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -1758,6 +1758,13 @@ pub enum ColumnOption {
17581758 /// ```
17591759 /// [Snowflake]: https://docs.snowflake.com/en/sql-reference/sql/create-table
17601760 Tags ( TagsColumnOption ) ,
1761+ /// MySQL specific: Spatial reference identifier
1762+ /// Syntax:
1763+ /// ```sql
1764+ /// CREATE TABLE geom (g GEOMETRY NOT NULL SRID 4326);
1765+ /// ```
1766+ /// [MySQL]: https://dev.mysql.com/doc/refman/8.4/en/creating-spatial-indexes.html
1767+ Srid ( Box < Expr > ) ,
17611768}
17621769
17631770impl fmt:: Display for ColumnOption {
@@ -1873,6 +1880,9 @@ impl fmt::Display for ColumnOption {
18731880 Tags ( tags) => {
18741881 write ! ( f, "{tags}" )
18751882 }
1883+ Srid ( srid) => {
1884+ write ! ( f, "SRID {srid}" )
1885+ }
18761886 }
18771887 }
18781888}
Original file line number Diff line number Diff line change @@ -871,6 +871,7 @@ impl Spanned for ColumnOption {
871871 ColumnOption :: OnConflict ( ..) => Span :: empty ( ) ,
872872 ColumnOption :: Policy ( ..) => Span :: empty ( ) ,
873873 ColumnOption :: Tags ( ..) => Span :: empty ( ) ,
874+ ColumnOption :: Srid ( ..) => Span :: empty ( ) ,
874875 }
875876 }
876877}
Original file line number Diff line number Diff line change @@ -844,6 +844,7 @@ define_keywords!(
844844 SQLSTATE ,
845845 SQLWARNING ,
846846 SQRT ,
847+ SRID ,
847848 STABLE ,
848849 STAGE ,
849850 START ,
Original file line number Diff line number Diff line change @@ -7754,6 +7754,10 @@ impl<'a> Parser<'a> {
77547754 && dialect_of!(self is MySqlDialect | SQLiteDialect | DuckDbDialect | GenericDialect)
77557755 {
77567756 self.parse_optional_column_option_as()
7757+ } else if self.parse_keyword(Keyword::SRID)
7758+ && dialect_of!(self is MySqlDialect | GenericDialect)
7759+ {
7760+ Ok(Some(ColumnOption::Srid(Box::new(self.parse_expr()?))))
77577761 } else if self.parse_keyword(Keyword::IDENTITY)
77587762 && dialect_of!(self is MsSqlDialect | GenericDialect)
77597763 {
Original file line number Diff line number Diff line change @@ -3745,6 +3745,11 @@ fn parse_begin_without_transaction() {
37453745 mysql ( ) . verified_stmt ( "BEGIN" ) ;
37463746}
37473747
3748+ #[ test]
3749+ fn parse_geometric_types_srid_option ( ) {
3750+ mysql_and_generic ( ) . verified_stmt ( "CREATE TABLE t (a geometry SRID 4326)" ) ;
3751+ }
3752+
37483753#[ test]
37493754fn parse_double_precision ( ) {
37503755 mysql ( ) . verified_stmt ( "CREATE TABLE foo (bar DOUBLE)" ) ;
You can’t perform that action at this time.
0 commit comments