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