@@ -18,6 +18,7 @@ mod operator;
18
18
mod query;
19
19
mod value;
20
20
21
+ use serde:: { Deserialize , Serialize } ;
21
22
use std:: fmt;
22
23
23
24
pub use self :: data_type:: DataType ;
70
71
}
71
72
72
73
/// An identifier, decomposed into its value or character data and the quote style.
73
- #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
74
+ #[ derive( Debug , Clone , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
74
75
pub struct Ident {
75
76
/// The value of the identifier without quotes.
76
77
pub value : String ,
@@ -126,7 +127,7 @@ impl fmt::Display for Ident {
126
127
}
127
128
128
129
/// A name of a table, view, custom type, etc., possibly multi-part, i.e. db.schema.obj
129
- #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
130
+ #[ derive( Debug , Clone , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
130
131
pub struct ObjectName ( pub Vec < Ident > ) ;
131
132
132
133
impl fmt:: Display for ObjectName {
@@ -140,7 +141,7 @@ impl fmt::Display for ObjectName {
140
141
/// The parser does not distinguish between expressions of different types
141
142
/// (e.g. boolean vs string), so the caller must handle expressions of
142
143
/// inappropriate type, like `WHERE 1` or `SELECT 1=1`, as necessary.
143
- #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
144
+ #[ derive( Debug , Clone , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
144
145
pub enum Expr {
145
146
/// Identifier e.g. table name or column name
146
147
Identifier ( Ident ) ,
@@ -303,7 +304,7 @@ impl fmt::Display for Expr {
303
304
/// Note: we only recognize a complete single expression as `<condition>`,
304
305
/// not `< 0` nor `1, 2, 3` as allowed in a `<simple when clause>` per
305
306
/// <https://jakewheat.github.io/sql-overview/sql-2011-foundation-grammar.html#simple-when-clause>
306
- #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
307
+ #[ derive( Debug , Clone , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
307
308
pub struct WhenClause {
308
309
pub condition : Expr ,
309
310
pub result : Expr ,
@@ -316,7 +317,7 @@ impl fmt::Display for WhenClause {
316
317
}
317
318
318
319
/// A window specification (i.e. `OVER (PARTITION BY .. ORDER BY .. etc.)`)
319
- #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
320
+ #[ derive( Debug , Clone , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
320
321
pub struct WindowSpec {
321
322
pub partition_by : Vec < Expr > ,
322
323
pub order_by : Vec < OrderByExpr > ,
@@ -361,7 +362,7 @@ impl fmt::Display for WindowSpec {
361
362
///
362
363
/// Note: The parser does not validate the specified bounds; the caller should
363
364
/// reject invalid bounds like `ROWS UNBOUNDED FOLLOWING` before execution.
364
- #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
365
+ #[ derive( Debug , Clone , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
365
366
pub struct WindowFrame {
366
367
pub units : WindowFrameUnits ,
367
368
pub start_bound : WindowFrameBound ,
@@ -372,7 +373,7 @@ pub struct WindowFrame {
372
373
// TBD: EXCLUDE
373
374
}
374
375
375
- #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
376
+ #[ derive( Debug , Clone , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
376
377
pub enum WindowFrameUnits {
377
378
Rows ,
378
379
Range ,
@@ -406,7 +407,7 @@ impl FromStr for WindowFrameUnits {
406
407
}
407
408
408
409
/// Specifies [WindowFrame]'s `start_bound` and `end_bound`
409
- #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
410
+ #[ derive( Debug , Clone , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
410
411
pub enum WindowFrameBound {
411
412
/// `CURRENT ROW`
412
413
CurrentRow ,
@@ -430,7 +431,7 @@ impl fmt::Display for WindowFrameBound {
430
431
431
432
/// A top-level statement (SELECT, INSERT, CREATE, etc.)
432
433
#[ allow( clippy:: large_enum_variant) ]
433
- #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
434
+ #[ derive( Debug , Clone , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
434
435
pub enum Statement {
435
436
/// SELECT
436
437
Query ( Box < Query > ) ,
@@ -774,7 +775,7 @@ impl fmt::Display for Statement {
774
775
}
775
776
776
777
/// SQL assignment `foo = expr` as used in SQLUpdate
777
- #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
778
+ #[ derive( Debug , Clone , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
778
779
pub struct Assignment {
779
780
pub id : Ident ,
780
781
pub value : Expr ,
@@ -787,7 +788,7 @@ impl fmt::Display for Assignment {
787
788
}
788
789
789
790
/// A function call
790
- #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
791
+ #[ derive( Debug , Clone , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
791
792
pub struct Function {
792
793
pub name : ObjectName ,
793
794
pub args : Vec < Expr > ,
@@ -813,7 +814,7 @@ impl fmt::Display for Function {
813
814
}
814
815
815
816
/// External table's available file format
816
- #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
817
+ #[ derive( Debug , Clone , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
817
818
pub enum FileFormat {
818
819
TEXTFILE ,
819
820
SEQUENCEFILE ,
@@ -864,7 +865,7 @@ impl FromStr for FileFormat {
864
865
865
866
/// A `LISTAGG` invocation `LISTAGG( [ DISTINCT ] <expr>[, <separator> ] [ON OVERFLOW <on_overflow>] ) )
866
867
/// [ WITHIN GROUP (ORDER BY <within_group1>[, ...] ) ]`
867
- #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
868
+ #[ derive( Debug , Clone , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
868
869
pub struct ListAgg {
869
870
pub distinct : bool ,
870
871
pub expr : Box < Expr > ,
@@ -900,7 +901,7 @@ impl fmt::Display for ListAgg {
900
901
}
901
902
902
903
/// The `ON OVERFLOW` clause of a LISTAGG invocation
903
- #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
904
+ #[ derive( Debug , Clone , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
904
905
pub enum ListAggOnOverflow {
905
906
/// `ON OVERFLOW ERROR`
906
907
Error ,
@@ -933,7 +934,7 @@ impl fmt::Display for ListAggOnOverflow {
933
934
}
934
935
}
935
936
936
- #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
937
+ #[ derive( Debug , Clone , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
937
938
pub enum ObjectType {
938
939
Table ,
939
940
View ,
@@ -952,7 +953,7 @@ impl fmt::Display for ObjectType {
952
953
}
953
954
}
954
955
955
- #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
956
+ #[ derive( Debug , Clone , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
956
957
pub struct SqlOption {
957
958
pub name : Ident ,
958
959
pub value : Value ,
@@ -964,7 +965,7 @@ impl fmt::Display for SqlOption {
964
965
}
965
966
}
966
967
967
- #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
968
+ #[ derive( Debug , Clone , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
968
969
pub enum TransactionMode {
969
970
AccessMode ( TransactionAccessMode ) ,
970
971
IsolationLevel ( TransactionIsolationLevel ) ,
@@ -980,7 +981,7 @@ impl fmt::Display for TransactionMode {
980
981
}
981
982
}
982
983
983
- #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
984
+ #[ derive( Debug , Clone , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
984
985
pub enum TransactionAccessMode {
985
986
ReadOnly ,
986
987
ReadWrite ,
@@ -996,7 +997,7 @@ impl fmt::Display for TransactionAccessMode {
996
997
}
997
998
}
998
999
999
- #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
1000
+ #[ derive( Debug , Clone , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
1000
1001
pub enum TransactionIsolationLevel {
1001
1002
ReadUncommitted ,
1002
1003
ReadCommitted ,
@@ -1016,7 +1017,7 @@ impl fmt::Display for TransactionIsolationLevel {
1016
1017
}
1017
1018
}
1018
1019
1019
- #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
1020
+ #[ derive( Debug , Clone , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
1020
1021
pub enum ShowStatementFilter {
1021
1022
Like ( String ) ,
1022
1023
Where ( Expr ) ,
@@ -1032,7 +1033,7 @@ impl fmt::Display for ShowStatementFilter {
1032
1033
}
1033
1034
}
1034
1035
1035
- #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
1036
+ #[ derive( Debug , Clone , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
1036
1037
pub enum SetVariableValue {
1037
1038
Ident ( Ident ) ,
1038
1039
Literal ( Value ) ,
0 commit comments