mirror of
				https://github.com/apache/datafusion-sqlparser-rs.git
				synced 2025-10-31 15:17:41 +00:00 
			
		
		
		
	Add support for ASC and DESC in CREATE TABLE column constraints for SQLite. (#1462)
This commit is contained in:
		
							parent
							
								
									8badcdc200
								
							
						
					
					
						commit
						ac956dc963
					
				
					 5 changed files with 63 additions and 0 deletions
				
			
		|  | @ -103,4 +103,8 @@ impl Dialect for GenericDialect { | |||
|     fn supports_limit_comma(&self) -> bool { | ||||
|         true | ||||
|     } | ||||
| 
 | ||||
|     fn supports_asc_desc_in_column_definition(&self) -> bool { | ||||
|         true | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -557,6 +557,10 @@ pub trait Dialect: Debug + Any { | |||
|     fn supports_explain_with_utility_options(&self) -> bool { | ||||
|         false | ||||
|     } | ||||
| 
 | ||||
|     fn supports_asc_desc_in_column_definition(&self) -> bool { | ||||
|         false | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /// This represents the operators for which precedence must be defined
 | ||||
|  |  | |||
|  | @ -77,4 +77,8 @@ impl Dialect for SQLiteDialect { | |||
|     fn supports_limit_comma(&self) -> bool { | ||||
|         true | ||||
|     } | ||||
| 
 | ||||
|     fn supports_asc_desc_in_column_definition(&self) -> bool { | ||||
|         true | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -6192,6 +6192,20 @@ impl<'a> Parser<'a> { | |||
|             Ok(Some(ColumnOption::DialectSpecific(vec![ | ||||
|                 Token::make_keyword("AUTOINCREMENT"), | ||||
|             ]))) | ||||
|         } else if self.parse_keyword(Keyword::ASC) | ||||
|             && self.dialect.supports_asc_desc_in_column_definition() | ||||
|         { | ||||
|             // Support ASC for SQLite
 | ||||
|             Ok(Some(ColumnOption::DialectSpecific(vec![ | ||||
|                 Token::make_keyword("ASC"), | ||||
|             ]))) | ||||
|         } else if self.parse_keyword(Keyword::DESC) | ||||
|             && self.dialect.supports_asc_desc_in_column_definition() | ||||
|         { | ||||
|             // Support DESC for SQLite
 | ||||
|             Ok(Some(ColumnOption::DialectSpecific(vec![ | ||||
|                 Token::make_keyword("DESC"), | ||||
|             ]))) | ||||
|         } else if self.parse_keywords(&[Keyword::ON, Keyword::UPDATE]) | ||||
|             && dialect_of!(self is MySqlDialect | GenericDialect) | ||||
|         { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 David Caldwell
						David Caldwell