1
1
use super :: { Expression , Identifier , OrderingTerm , WindowDefinition } ;
2
+ use std:: fmt:: Display ;
2
3
3
4
/// An enum representing the possible types of SELECT statements
4
5
#[ derive( Debug , PartialEq , Clone ) ]
@@ -130,7 +131,7 @@ pub struct JoinClause {
130
131
pub struct JoinTable {
131
132
pub join_type : JoinType ,
132
133
pub table : Box < SelectFrom > ,
133
- pub constraints : JoinConstraint ,
134
+ pub constraints : Option < JoinConstraint > ,
134
135
}
135
136
136
137
/// A type alias for the `NATURAL` keyword in a JOIN clause
@@ -151,13 +152,33 @@ pub enum JoinType {
151
152
Cross ,
152
153
}
153
154
155
+ impl Display for JoinType {
156
+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
157
+ match self {
158
+ JoinType :: Left ( is_natural) => {
159
+ write ! ( f, "{} LEFT" , if * is_natural { "NATURAL" } else { "" } )
160
+ }
161
+ JoinType :: Right ( is_natural) => {
162
+ write ! ( f, "{} RIGHT" , if * is_natural { "NATURAL" } else { "" } )
163
+ }
164
+ JoinType :: Full ( is_natural) => {
165
+ write ! ( f, "{} FULL" , if * is_natural { "NATURAL" } else { "" } )
166
+ }
167
+ JoinType :: Inner ( is_natural) => {
168
+ write ! ( f, "{} INNER" , if * is_natural { "NATURAL" } else { "" } )
169
+ }
170
+ JoinType :: Cross => write ! ( f, "CROSS" ) ,
171
+ }
172
+ }
173
+ }
174
+
154
175
/// A constraint for a JOIN clause
155
176
#[ derive( Debug , PartialEq , Clone ) ]
156
177
pub enum JoinConstraint {
157
178
/// ON clause
158
179
On ( Expression ) ,
159
180
/// USING clause
160
- Using ( Vec < String > ) ,
181
+ Using ( Vec < Identifier > ) ,
161
182
}
162
183
163
184
/// A clause for a LIMIT statement
0 commit comments