1
1
//! AST types specific to CREATE/ALTER variants of `SQLStatement`
2
2
//! (commonly referred to as Data Definition Language, or DDL)
3
- use super :: { Expr , SQLIdent , SQLObjectName } ;
3
+ use super :: { Expr , Ident , ObjectName } ;
4
4
5
5
/// An `ALTER TABLE` (`SQLStatement::SQLAlterTable`) operation
6
6
#[ derive( Debug , Clone , PartialEq , Hash ) ]
7
7
pub enum AlterTableOperation {
8
8
/// `ADD <table_constraint>`
9
9
AddConstraint ( TableConstraint ) ,
10
10
/// TODO: implement `DROP CONSTRAINT <name>`
11
- DropConstraint { name : SQLIdent } ,
11
+ DropConstraint { name : Ident } ,
12
12
}
13
13
14
14
impl ToString for AlterTableOperation {
@@ -26,29 +26,29 @@ impl ToString for AlterTableOperation {
26
26
pub enum TableConstraint {
27
27
/// `[ CONSTRAINT <name> ] { PRIMARY KEY | UNIQUE } (<columns>)`
28
28
Unique {
29
- name : Option < SQLIdent > ,
30
- columns : Vec < SQLIdent > ,
29
+ name : Option < Ident > ,
30
+ columns : Vec < Ident > ,
31
31
/// Whether this is a `PRIMARY KEY` or just a `UNIQUE` constraint
32
32
is_primary : bool ,
33
33
} ,
34
34
/// A referential integrity constraint (`[ CONSTRAINT <name> ] FOREIGN KEY (<columns>)
35
35
/// REFERENCES <foreign_table> (<referred_columns>)`)
36
36
ForeignKey {
37
- name : Option < SQLIdent > ,
38
- columns : Vec < SQLIdent > ,
39
- foreign_table : SQLObjectName ,
40
- referred_columns : Vec < SQLIdent > ,
37
+ name : Option < Ident > ,
38
+ columns : Vec < Ident > ,
39
+ foreign_table : ObjectName ,
40
+ referred_columns : Vec < Ident > ,
41
41
} ,
42
42
/// `[ CONSTRAINT <name> ] CHECK (<expr>)`
43
43
Check {
44
- name : Option < SQLIdent > ,
44
+ name : Option < Ident > ,
45
45
expr : Box < Expr > ,
46
46
} ,
47
47
}
48
48
49
49
impl ToString for TableConstraint {
50
50
fn to_string ( & self ) -> String {
51
- fn format_constraint_name ( name : & Option < SQLIdent > ) -> String {
51
+ fn format_constraint_name ( name : & Option < Ident > ) -> String {
52
52
name. as_ref ( )
53
53
. map ( |name| format ! ( "CONSTRAINT {} " , name) )
54
54
. unwrap_or_default ( )
0 commit comments