@@ -20,7 +20,7 @@ mod sqltype;
20
20
mod table_key;
21
21
mod value;
22
22
23
- pub use self :: query:: SQLSelect ;
23
+ pub use self :: query:: { Join , JoinConstraint , JoinOperator , SQLOrderByExpr , SQLSelect } ;
24
24
pub use self :: sqltype:: SQLType ;
25
25
pub use self :: table_key:: { AlterOperation , Key , TableKey } ;
26
26
pub use self :: value:: Value ;
@@ -308,29 +308,6 @@ impl ToString for SQLAssignment {
308
308
}
309
309
}
310
310
311
- /// SQL ORDER BY expression
312
- #[ derive( Debug , Clone , PartialEq ) ]
313
- pub struct SQLOrderByExpr {
314
- pub expr : Box < ASTNode > ,
315
- pub asc : Option < bool > ,
316
- }
317
-
318
- impl SQLOrderByExpr {
319
- pub fn new ( expr : Box < ASTNode > , asc : Option < bool > ) -> Self {
320
- SQLOrderByExpr { expr, asc }
321
- }
322
- }
323
-
324
- impl ToString for SQLOrderByExpr {
325
- fn to_string ( & self ) -> String {
326
- match self . asc {
327
- Some ( true ) => format ! ( "{} ASC" , self . expr. to_string( ) ) ,
328
- Some ( false ) => format ! ( "{} DESC" , self . expr. to_string( ) ) ,
329
- None => self . expr . to_string ( ) ,
330
- }
331
- }
332
- }
333
-
334
311
/// SQL column definition
335
312
#[ derive( Debug , Clone , PartialEq ) ]
336
313
pub struct SQLColumnDef {
@@ -360,72 +337,3 @@ impl ToString for SQLColumnDef {
360
337
s
361
338
}
362
339
}
363
-
364
- #[ derive( Debug , Clone , PartialEq ) ]
365
- pub struct Join {
366
- pub relation : ASTNode , // TableFactor
367
- pub join_operator : JoinOperator ,
368
- }
369
-
370
- impl ToString for Join {
371
- fn to_string ( & self ) -> String {
372
- fn prefix ( constraint : & JoinConstraint ) -> String {
373
- match constraint {
374
- JoinConstraint :: Natural => "NATURAL " . to_string ( ) ,
375
- _ => "" . to_string ( ) ,
376
- }
377
- }
378
- fn suffix ( constraint : & JoinConstraint ) -> String {
379
- match constraint {
380
- JoinConstraint :: On ( expr) => format ! ( "ON {}" , expr. to_string( ) ) ,
381
- JoinConstraint :: Using ( attrs) => format ! ( "USING({})" , attrs. join( ", " ) ) ,
382
- _ => "" . to_string ( ) ,
383
- }
384
- }
385
- match & self . join_operator {
386
- JoinOperator :: Inner ( constraint) => format ! (
387
- " {}JOIN {} {}" ,
388
- prefix( constraint) ,
389
- self . relation. to_string( ) ,
390
- suffix( constraint)
391
- ) ,
392
- JoinOperator :: Cross => format ! ( " CROSS JOIN {}" , self . relation. to_string( ) ) ,
393
- JoinOperator :: Implicit => format ! ( ", {}" , self . relation. to_string( ) ) ,
394
- JoinOperator :: LeftOuter ( constraint) => format ! (
395
- " {}LEFT JOIN {} {}" ,
396
- prefix( constraint) ,
397
- self . relation. to_string( ) ,
398
- suffix( constraint)
399
- ) ,
400
- JoinOperator :: RightOuter ( constraint) => format ! (
401
- " {}RIGHT JOIN {} {}" ,
402
- prefix( constraint) ,
403
- self . relation. to_string( ) ,
404
- suffix( constraint)
405
- ) ,
406
- JoinOperator :: FullOuter ( constraint) => format ! (
407
- " {}FULL JOIN {} {}" ,
408
- prefix( constraint) ,
409
- self . relation. to_string( ) ,
410
- suffix( constraint)
411
- ) ,
412
- }
413
- }
414
- }
415
-
416
- #[ derive( Debug , Clone , PartialEq ) ]
417
- pub enum JoinOperator {
418
- Inner ( JoinConstraint ) ,
419
- LeftOuter ( JoinConstraint ) ,
420
- RightOuter ( JoinConstraint ) ,
421
- FullOuter ( JoinConstraint ) ,
422
- Implicit ,
423
- Cross ,
424
- }
425
-
426
- #[ derive( Debug , Clone , PartialEq ) ]
427
- pub enum JoinConstraint {
428
- On ( ASTNode ) ,
429
- Using ( Vec < String > ) ,
430
- Natural ,
431
- }
0 commit comments