From 7710451d7ba64e13cc644bdd3b2b4901471d7146 Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Wed, 23 Feb 2022 11:18:46 +0000 Subject: [PATCH] Remove serde serialization field skipping Due to a bug in msgpack-rust (https://github.com/3Hren/msgpack-rust/issues/86), in order to have correct serialization<->deserialization of data, we need to ensure all fields are serialized even when empty. This will affect the output size of the data, but will ensure that once serialized, the data is deserialized without issue. --- lib/src/sql/graph.rs | 2 -- lib/src/sql/model.rs | 2 -- lib/src/sql/statements/create.rs | 3 --- lib/src/sql/statements/define.rs | 11 ----------- lib/src/sql/statements/delete.rs | 3 --- lib/src/sql/statements/ifelse.rs | 1 - lib/src/sql/statements/insert.rs | 3 --- lib/src/sql/statements/live.rs | 2 -- lib/src/sql/statements/relate.rs | 3 --- lib/src/sql/statements/select.rs | 9 --------- lib/src/sql/statements/update.rs | 4 ---- lib/src/sql/statements/yuse.rs | 2 -- lib/src/sql/view.rs | 2 -- 13 files changed, 47 deletions(-) diff --git a/lib/src/sql/graph.rs b/lib/src/sql/graph.rs index c89c4b99..da68c9b3 100644 --- a/lib/src/sql/graph.rs +++ b/lib/src/sql/graph.rs @@ -38,9 +38,7 @@ impl fmt::Display for Dir { pub struct Graph { pub dir: Dir, pub what: Tables, - #[serde(skip_serializing_if = "Option::is_none")] pub cond: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub alias: Option, } diff --git a/lib/src/sql/model.rs b/lib/src/sql/model.rs index b12af09f..28248c85 100644 --- a/lib/src/sql/model.rs +++ b/lib/src/sql/model.rs @@ -11,9 +11,7 @@ use std::fmt; #[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize)] pub struct Model { pub table: String, - #[serde(skip_serializing_if = "Option::is_none")] pub count: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub range: Option<(u64, u64)>, } diff --git a/lib/src/sql/statements/create.rs b/lib/src/sql/statements/create.rs index bb3aaca5..36254791 100644 --- a/lib/src/sql/statements/create.rs +++ b/lib/src/sql/statements/create.rs @@ -20,11 +20,8 @@ use std::fmt; #[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)] pub struct CreateStatement { pub what: Values, - #[serde(skip_serializing_if = "Option::is_none")] pub data: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub output: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub timeout: Option, } diff --git a/lib/src/sql/statements/define.rs b/lib/src/sql/statements/define.rs index 622bc941..8932a1d0 100644 --- a/lib/src/sql/statements/define.rs +++ b/lib/src/sql/statements/define.rs @@ -186,9 +186,7 @@ fn database(i: &str) -> IResult<&str, DefineDatabaseStatement> { pub struct DefineLoginStatement { pub name: String, pub base: Base, - #[serde(skip_serializing_if = "Option::is_none")] pub pass: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub hash: Option, } @@ -355,13 +353,9 @@ fn token(i: &str) -> IResult<&str, DefineTokenStatement> { #[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)] pub struct DefineScopeStatement { pub name: String, - #[serde(skip_serializing_if = "Option::is_none")] pub session: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub signup: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub signin: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub connect: Option, } @@ -483,7 +477,6 @@ pub struct DefineTableStatement { pub name: String, pub drop: bool, pub full: bool, - #[serde(skip_serializing_if = "Option::is_none")] pub view: Option, pub permissions: Permissions, } @@ -682,13 +675,9 @@ fn event(i: &str) -> IResult<&str, DefineEventStatement> { pub struct DefineFieldStatement { pub name: Idiom, pub what: String, - #[serde(skip_serializing_if = "Option::is_none")] pub kind: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub value: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub assert: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub priority: Option, pub permissions: Permissions, } diff --git a/lib/src/sql/statements/delete.rs b/lib/src/sql/statements/delete.rs index 865b3375..be4bb01e 100644 --- a/lib/src/sql/statements/delete.rs +++ b/lib/src/sql/statements/delete.rs @@ -21,11 +21,8 @@ use std::fmt; #[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)] pub struct DeleteStatement { pub what: Values, - #[serde(skip_serializing_if = "Option::is_none")] pub cond: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub output: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub timeout: Option, } diff --git a/lib/src/sql/statements/ifelse.rs b/lib/src/sql/statements/ifelse.rs index 468de82a..cb6445e0 100644 --- a/lib/src/sql/statements/ifelse.rs +++ b/lib/src/sql/statements/ifelse.rs @@ -14,7 +14,6 @@ use std::fmt; #[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)] pub struct IfelseStatement { pub exprs: Vec<(Value, Value)>, - #[serde(skip_serializing_if = "Option::is_none")] pub close: Option, } diff --git a/lib/src/sql/statements/insert.rs b/lib/src/sql/statements/insert.rs index 2d0e7321..79d28b54 100644 --- a/lib/src/sql/statements/insert.rs +++ b/lib/src/sql/statements/insert.rs @@ -24,11 +24,8 @@ pub struct InsertStatement { pub into: Table, pub data: Data, pub ignore: bool, - #[serde(skip_serializing_if = "Option::is_none")] pub update: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub output: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub timeout: Option, } diff --git a/lib/src/sql/statements/live.rs b/lib/src/sql/statements/live.rs index a1e1c818..0149e9ef 100644 --- a/lib/src/sql/statements/live.rs +++ b/lib/src/sql/statements/live.rs @@ -19,9 +19,7 @@ use std::fmt; pub struct LiveStatement { pub expr: Fields, pub what: Values, - #[serde(skip_serializing_if = "Option::is_none")] pub cond: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub fetch: Option, } diff --git a/lib/src/sql/statements/relate.rs b/lib/src/sql/statements/relate.rs index 1627401d..01c06a34 100644 --- a/lib/src/sql/statements/relate.rs +++ b/lib/src/sql/statements/relate.rs @@ -27,11 +27,8 @@ pub struct RelateStatement { pub from: Values, pub with: Values, pub uniq: bool, - #[serde(skip_serializing_if = "Option::is_none")] pub data: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub output: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub timeout: Option, } diff --git a/lib/src/sql/statements/select.rs b/lib/src/sql/statements/select.rs index a43b2779..9685f570 100644 --- a/lib/src/sql/statements/select.rs +++ b/lib/src/sql/statements/select.rs @@ -28,23 +28,14 @@ use std::fmt; pub struct SelectStatement { pub expr: Fields, pub what: Values, - #[serde(skip_serializing_if = "Option::is_none")] pub cond: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub split: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub group: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub order: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub limit: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub start: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub fetch: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub version: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub timeout: Option, } diff --git a/lib/src/sql/statements/update.rs b/lib/src/sql/statements/update.rs index 2054a8d5..7ac3f1f7 100644 --- a/lib/src/sql/statements/update.rs +++ b/lib/src/sql/statements/update.rs @@ -21,13 +21,9 @@ use std::fmt; #[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)] pub struct UpdateStatement { pub what: Values, - #[serde(skip_serializing_if = "Option::is_none")] pub data: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub cond: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub output: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub timeout: Option, } diff --git a/lib/src/sql/statements/yuse.rs b/lib/src/sql/statements/yuse.rs index a121a6e7..bfdff273 100644 --- a/lib/src/sql/statements/yuse.rs +++ b/lib/src/sql/statements/yuse.rs @@ -8,9 +8,7 @@ use std::fmt; #[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)] pub struct UseStatement { - #[serde(skip_serializing_if = "Option::is_none")] pub ns: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub db: Option, } diff --git a/lib/src/sql/view.rs b/lib/src/sql/view.rs index 2ab24836..3c615e32 100644 --- a/lib/src/sql/view.rs +++ b/lib/src/sql/view.rs @@ -14,9 +14,7 @@ use std::fmt; pub struct View { pub expr: Fields, pub what: Tables, - #[serde(skip_serializing_if = "Option::is_none")] pub cond: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub group: Option, }