@@ -32,8 +32,9 @@ use crate::ast::value::escape_single_quote_string;
32
32
use crate :: ast:: {
33
33
display_comma_separated, display_separated, CommentDef , CreateFunctionBody ,
34
34
CreateFunctionUsing , DataType , Expr , FunctionBehavior , FunctionCalledOnNull ,
35
- FunctionDeterminismSpecifier , FunctionParallel , Ident , MySQLColumnPosition , ObjectName ,
36
- OperateFunctionArg , OrderByExpr , ProjectionSelect , SequenceOptions , SqlOption , Tag , Value ,
35
+ FunctionDeterminismSpecifier , FunctionParallel , Ident , IndexField , MySQLColumnPosition ,
36
+ ObjectName , OperateFunctionArg , OrderByExpr , ProjectionSelect , SequenceOptions , SqlOption , Tag ,
37
+ Value ,
37
38
} ;
38
39
use crate :: keywords:: Keyword ;
39
40
use crate :: tokenizer:: Token ;
@@ -832,8 +833,8 @@ pub enum TableConstraint {
832
833
///
833
834
/// [1]: IndexType
834
835
index_type : Option < IndexType > ,
835
- /// Identifiers of the columns that are unique .
836
- columns : Vec < Ident > ,
836
+ /// Index field list .
837
+ index_fields : Vec < IndexField > ,
837
838
index_options : Vec < IndexOption > ,
838
839
characteristics : Option < ConstraintCharacteristics > ,
839
840
/// Optional Postgres nulls handling: `[ NULLS [ NOT ] DISTINCT ]`
@@ -868,8 +869,8 @@ pub enum TableConstraint {
868
869
///
869
870
/// [1]: IndexType
870
871
index_type : Option < IndexType > ,
871
- /// Identifiers of the columns that form the primary key.
872
- columns : Vec < Ident > ,
872
+ /// Index field list that form the primary key.
873
+ index_fields : Vec < IndexField > ,
873
874
index_options : Vec < IndexOption > ,
874
875
characteristics : Option < ConstraintCharacteristics > ,
875
876
} ,
@@ -907,8 +908,10 @@ pub enum TableConstraint {
907
908
///
908
909
/// [1]: IndexType
909
910
index_type : Option < IndexType > ,
910
- /// Referred column identifier list.
911
- columns : Vec < Ident > ,
911
+ /// [Index field list][1].
912
+ ///
913
+ /// [1]: IndexField
914
+ index_fields : Vec < IndexField > ,
912
915
} ,
913
916
/// MySQLs [fulltext][1] definition. Since the [`SPATIAL`][2] definition is exactly the same,
914
917
/// and MySQL displays both the same way, it is part of this definition as well.
@@ -930,8 +933,8 @@ pub enum TableConstraint {
930
933
index_type_display : KeyOrIndexDisplay ,
931
934
/// Optional index name.
932
935
opt_index_name : Option < Ident > ,
933
- /// Referred column identifier list.
934
- columns : Vec < Ident > ,
936
+ /// Index field list.
937
+ index_fields : Vec < IndexField > ,
935
938
} ,
936
939
}
937
940
@@ -943,7 +946,7 @@ impl fmt::Display for TableConstraint {
943
946
index_name,
944
947
index_type_display,
945
948
index_type,
946
- columns ,
949
+ index_fields ,
947
950
index_options,
948
951
characteristics,
949
952
nulls_distinct,
@@ -954,7 +957,7 @@ impl fmt::Display for TableConstraint {
954
957
display_constraint_name( name) ,
955
958
display_option_spaced( index_name) ,
956
959
display_option( " USING " , "" , index_type) ,
957
- display_comma_separated( columns ) ,
960
+ display_comma_separated( index_fields ) ,
958
961
) ?;
959
962
960
963
if !index_options. is_empty ( ) {
@@ -968,7 +971,7 @@ impl fmt::Display for TableConstraint {
968
971
name,
969
972
index_name,
970
973
index_type,
971
- columns ,
974
+ index_fields ,
972
975
index_options,
973
976
characteristics,
974
977
} => {
@@ -978,7 +981,7 @@ impl fmt::Display for TableConstraint {
978
981
display_constraint_name( name) ,
979
982
display_option_spaced( index_name) ,
980
983
display_option( " USING " , "" , index_type) ,
981
- display_comma_separated( columns ) ,
984
+ display_comma_separated( index_fields ) ,
982
985
) ?;
983
986
984
987
if !index_options. is_empty ( ) {
@@ -1025,7 +1028,7 @@ impl fmt::Display for TableConstraint {
1025
1028
display_as_key,
1026
1029
name,
1027
1030
index_type,
1028
- columns ,
1031
+ index_fields ,
1029
1032
} => {
1030
1033
write ! ( f, "{}" , if * display_as_key { "KEY" } else { "INDEX" } ) ?;
1031
1034
if let Some ( name) = name {
@@ -1034,15 +1037,16 @@ impl fmt::Display for TableConstraint {
1034
1037
if let Some ( index_type) = index_type {
1035
1038
write ! ( f, " USING {index_type}" ) ?;
1036
1039
}
1037
- write ! ( f, " ({})" , display_comma_separated( columns) ) ?;
1040
+
1041
+ write ! ( f, " ({})" , display_comma_separated( index_fields) ) ?;
1038
1042
1039
1043
Ok ( ( ) )
1040
1044
}
1041
1045
Self :: FulltextOrSpatial {
1042
1046
fulltext,
1043
1047
index_type_display,
1044
1048
opt_index_name,
1045
- columns ,
1049
+ index_fields ,
1046
1050
} => {
1047
1051
if * fulltext {
1048
1052
write ! ( f, "FULLTEXT" ) ?;
@@ -1056,7 +1060,7 @@ impl fmt::Display for TableConstraint {
1056
1060
write ! ( f, " {name}" ) ?;
1057
1061
}
1058
1062
1059
- write ! ( f, " ({})" , display_comma_separated( columns ) ) ?;
1063
+ write ! ( f, " ({})" , display_comma_separated( index_fields ) ) ?;
1060
1064
1061
1065
Ok ( ( ) )
1062
1066
}
0 commit comments