@@ -908,6 +908,117 @@ fn parse_create_table_with_invalid_options() {
908
908
}
909
909
}
910
910
911
+ #[ test]
912
+ fn parse_create_table_with_identity_column ( ) {
913
+ let with_column_options = [
914
+ (
915
+ r#"CREATE TABLE mytable (columnA INT IDENTITY NOT NULL)"# ,
916
+ vec ! [
917
+ ColumnOptionDef {
918
+ name: None ,
919
+ option: ColumnOption :: Identity ( None ) ,
920
+ } ,
921
+ ColumnOptionDef {
922
+ name: None ,
923
+ option: ColumnOption :: NotNull ,
924
+ } ,
925
+ ] ,
926
+ ) ,
927
+ (
928
+ r#"CREATE TABLE mytable (columnA INT IDENTITY(1, 1) NOT NULL)"# ,
929
+ vec ! [
930
+ ColumnOptionDef {
931
+ name: None ,
932
+ #[ cfg( not( feature = "bigdecimal" ) ) ]
933
+ option: ColumnOption :: Identity ( Some ( IdentityProperty {
934
+ seed: Expr :: Value ( Value :: Number ( "1" . to_string( ) , false ) ) ,
935
+ increment: Expr :: Value ( Value :: Number ( "1" . to_string( ) , false ) ) ,
936
+ } ) ) ,
937
+ #[ cfg( feature = "bigdecimal" ) ]
938
+ option: ColumnOption :: Identity ( Some ( IdentityProperty {
939
+ seed: Expr :: Value ( Value :: Number ( bigdecimal:: BigDecimal :: from( 1 ) , false ) ) ,
940
+ increment: Expr :: Value ( Value :: Number (
941
+ bigdecimal:: BigDecimal :: from( 1 ) ,
942
+ false ,
943
+ ) ) ,
944
+ } ) ) ,
945
+ } ,
946
+ ColumnOptionDef {
947
+ name: None ,
948
+ option: ColumnOption :: NotNull ,
949
+ } ,
950
+ ] ,
951
+ ) ,
952
+ ] ;
953
+
954
+ for ( sql, column_options) in with_column_options {
955
+ assert_eq ! (
956
+ ms_and_generic( ) . verified_stmt( sql) ,
957
+ Statement :: CreateTable ( CreateTable {
958
+ or_replace: false ,
959
+ temporary: false ,
960
+ external: false ,
961
+ global: None ,
962
+ if_not_exists: false ,
963
+ transient: false ,
964
+ volatile: false ,
965
+ name: ObjectName ( vec![ Ident {
966
+ value: "mytable" . to_string( ) ,
967
+ quote_style: None ,
968
+ } , ] , ) ,
969
+ columns: vec![ ColumnDef {
970
+ name: Ident {
971
+ value: "columnA" . to_string( ) ,
972
+ quote_style: None ,
973
+ } ,
974
+ data_type: Int ( None , ) ,
975
+ collation: None ,
976
+ options: column_options,
977
+ } , ] ,
978
+ constraints: vec![ ] ,
979
+ hive_distribution: HiveDistributionStyle :: NONE ,
980
+ hive_formats: Some ( HiveFormat {
981
+ row_format: None ,
982
+ serde_properties: None ,
983
+ storage: None ,
984
+ location: None ,
985
+ } , ) ,
986
+ table_properties: vec![ ] ,
987
+ with_options: vec![ ] ,
988
+ file_format: None ,
989
+ location: None ,
990
+ query: None ,
991
+ without_rowid: false ,
992
+ like: None ,
993
+ clone: None ,
994
+ engine: None ,
995
+ comment: None ,
996
+ auto_increment_offset: None ,
997
+ default_charset: None ,
998
+ collation: None ,
999
+ on_commit: None ,
1000
+ on_cluster: None ,
1001
+ primary_key: None ,
1002
+ order_by: None ,
1003
+ partition_by: None ,
1004
+ cluster_by: None ,
1005
+ clustered_by: None ,
1006
+ options: None ,
1007
+ strict: false ,
1008
+ copy_grants: false ,
1009
+ enable_schema_evolution: None ,
1010
+ change_tracking: None ,
1011
+ data_retention_time_in_days: None ,
1012
+ max_data_extension_time_in_days: None ,
1013
+ default_ddl_collation: None ,
1014
+ with_aggregation_policy: None ,
1015
+ with_row_access_policy: None ,
1016
+ with_tags: None ,
1017
+ } ) ,
1018
+ ) ;
1019
+ }
1020
+ }
1021
+
911
1022
fn ms ( ) -> TestedDialects {
912
1023
TestedDialects {
913
1024
dialects : vec ! [ Box :: new( MsSqlDialect { } ) ] ,
0 commit comments