File tree Expand file tree Collapse file tree 5 files changed +51
-1
lines changed
Expand file tree Collapse file tree 5 files changed +51
-1
lines changed Original file line number Diff line number Diff line change @@ -1911,6 +1911,13 @@ pub enum ColumnOption {
19111911 /// ```
19121912 /// [MySQL]: https://dev.mysql.com/doc/refman/8.4/en/creating-spatial-indexes.html
19131913 Srid ( Box < Expr > ) ,
1914+ /// MySQL specific: Column is invisible via SELECT *
1915+ /// Syntax:
1916+ /// ```sql
1917+ /// CREATE TABLE t (foo INT, bar INT INVISIBLE);
1918+ /// ```
1919+ /// [MySQL]: https://dev.mysql.com/doc/refman/8.4/en/invisible-columns.html
1920+ Invisible ,
19141921}
19151922
19161923impl fmt:: Display for ColumnOption {
@@ -2029,6 +2036,9 @@ impl fmt::Display for ColumnOption {
20292036 Srid ( srid) => {
20302037 write ! ( f, "SRID {srid}" )
20312038 }
2039+ Invisible => {
2040+ write ! ( f, "INVISIBLE" )
2041+ }
20322042 }
20332043 }
20342044}
Original file line number Diff line number Diff line change @@ -918,6 +918,7 @@ impl Spanned for ColumnOption {
918918 ColumnOption :: Policy ( ..) => Span :: empty ( ) ,
919919 ColumnOption :: Tags ( ..) => Span :: empty ( ) ,
920920 ColumnOption :: Srid ( ..) => Span :: empty ( ) ,
921+ ColumnOption :: Invisible => Span :: empty ( ) ,
921922 }
922923 }
923924}
Original file line number Diff line number Diff line change @@ -499,6 +499,7 @@ define_keywords!(
499499 INTERSECTION ,
500500 INTERVAL ,
501501 INTO ,
502+ INVISIBLE ,
502503 INVOKER ,
503504 IO ,
504505 IS ,
Original file line number Diff line number Diff line change @@ -8144,7 +8144,13 @@ impl<'a> Parser<'a> {
81448144 Keyword::REPLACE,
81458145 ])?,
81468146 )))
8147- } else {
8147+ } else if dialect_of!(self is MySqlDialect | GenericDialect)
8148+ && self.parse_keyword(Keyword::INVISIBLE)
8149+ {
8150+ // Support INVISIBLE for MySQL
8151+ Ok(Some(ColumnOption::Invisible))
8152+ }
8153+ else {
81488154 Ok(None)
81498155 }
81508156 }
Original file line number Diff line number Diff line change @@ -4247,3 +4247,35 @@ fn test_create_index_options() {
42474247 "CREATE INDEX idx_name ON t(c1, c2) USING BTREE LOCK = EXCLUSIVE ALGORITHM = DEFAULT" ,
42484248 ) ;
42494249}
4250+
4251+ #[ test]
4252+ fn parse_invisible_column ( ) {
4253+ mysql ( ) . verified_stmt ( "CREATE TABLE t (foo INT, bar INT INVISIBLE)" ) ;
4254+ mysql ( ) . verified_stmt ( "ALTER TABLE t ADD COLUMN bar INT INVISIBLE" ) ;
4255+ let stmt = mysql ( ) . verified_stmt ( "CREATE TABLE t (foo INT, bar INT INVISIBLE)" ) ;
4256+ match stmt {
4257+ Statement :: CreateTable ( CreateTable { columns, .. } ) => {
4258+ assert_eq ! (
4259+ columns,
4260+ vec![
4261+ ColumnDef {
4262+ name: "foo" . into( ) ,
4263+ data_type: DataType :: Int ( None ) ,
4264+ options: vec![ ] ,
4265+ } ,
4266+ ColumnDef {
4267+ name: "bar" . into( ) ,
4268+ data_type: DataType :: Int ( None ) ,
4269+ options: vec![
4270+ ColumnOptionDef {
4271+ name: None ,
4272+ option: ColumnOption :: Invisible ,
4273+ } ,
4274+ ] ,
4275+ }
4276+ ]
4277+ ) ;
4278+ }
4279+ _ => panic ! ( "Unexpected statement {stmt}" ) ,
4280+ }
4281+ }
You can’t perform that action at this time.
0 commit comments