From 7bb89d5041a627ab47ef1ac30a01630a442438a1 Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Sun, 2 Apr 2023 00:28:01 +0100 Subject: [PATCH] Ensure `DEFINE` and `REMOVE` statements are serialized with full field information --- lib/src/sql/statements/define.rs | 13 ++++++++++++- lib/src/sql/statements/remove.rs | 11 +++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/lib/src/sql/statements/define.rs b/lib/src/sql/statements/define.rs index dd591888..9ba02c1b 100644 --- a/lib/src/sql/statements/define.rs +++ b/lib/src/sql/statements/define.rs @@ -119,6 +119,7 @@ pub fn define(i: &str) -> IResult<&str, DefineStatement> { // -------------------------------------------------- #[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)] +#[format(Named)] pub struct DefineNamespaceStatement { pub name: Ident, } @@ -168,6 +169,7 @@ fn namespace(i: &str) -> IResult<&str, DefineNamespaceStatement> { // -------------------------------------------------- #[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)] +#[format(Named)] pub struct DefineDatabaseStatement { pub name: Ident, } @@ -222,6 +224,7 @@ fn database(i: &str) -> IResult<&str, DefineDatabaseStatement> { // -------------------------------------------------- #[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)] +#[format(Named)] pub struct DefineFunctionStatement { pub name: Ident, pub args: Vec<(Ident, Kind)>, @@ -306,6 +309,7 @@ fn function(i: &str) -> IResult<&str, DefineFunctionStatement> { // -------------------------------------------------- #[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)] +#[format(Named)] pub struct DefineLoginStatement { pub name: Ident, pub base: Base, @@ -429,6 +433,7 @@ fn login_hash(i: &str) -> IResult<&str, DefineLoginOption> { // -------------------------------------------------- #[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)] +#[format(Named)] pub struct DefineTokenStatement { pub name: Ident, pub base: Base, @@ -548,6 +553,7 @@ fn token(i: &str) -> IResult<&str, DefineTokenStatement> { // -------------------------------------------------- #[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)] +#[format(Named)] pub struct DefineScopeStatement { pub name: Ident, pub code: String, @@ -670,6 +676,7 @@ fn scope_signin(i: &str) -> IResult<&str, DefineScopeOption> { // -------------------------------------------------- #[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)] +#[format(Named)] pub struct DefineParamStatement { pub name: Ident, pub value: Value, @@ -732,6 +739,7 @@ fn param(i: &str) -> IResult<&str, DefineParamStatement> { // -------------------------------------------------- #[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)] +#[format(Named)] pub struct DefineTableStatement { pub name: Ident, pub drop: bool, @@ -916,6 +924,7 @@ fn table_permissions(i: &str) -> IResult<&str, DefineTableOption> { // -------------------------------------------------- #[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)] +#[format(Named)] pub struct DefineEventStatement { pub name: Ident, pub what: Ident, @@ -998,14 +1007,15 @@ fn event(i: &str) -> IResult<&str, DefineEventStatement> { // -------------------------------------------------- #[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)] +#[format(Named)] pub struct DefineFieldStatement { pub name: Idiom, pub what: Ident, + pub flex: bool, pub kind: Option, pub value: Option, pub assert: Option, pub permissions: Permissions, - pub flex: bool, } impl DefineFieldStatement { @@ -1161,6 +1171,7 @@ fn field_permissions(i: &str) -> IResult<&str, DefineFieldOption> { // -------------------------------------------------- #[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)] +#[format(Named)] pub struct DefineIndexStatement { pub name: Ident, pub what: Ident, diff --git a/lib/src/sql/statements/remove.rs b/lib/src/sql/statements/remove.rs index 8099e436..fa8d1a51 100644 --- a/lib/src/sql/statements/remove.rs +++ b/lib/src/sql/statements/remove.rs @@ -100,6 +100,7 @@ pub fn remove(i: &str) -> IResult<&str, RemoveStatement> { // -------------------------------------------------- #[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)] +#[format(Named)] pub struct RemoveNamespaceStatement { pub name: Ident, } @@ -156,6 +157,7 @@ fn namespace(i: &str) -> IResult<&str, RemoveNamespaceStatement> { // -------------------------------------------------- #[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)] +#[format(Named)] pub struct RemoveDatabaseStatement { pub name: Ident, } @@ -212,6 +214,7 @@ fn database(i: &str) -> IResult<&str, RemoveDatabaseStatement> { // -------------------------------------------------- #[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)] +#[format(Named)] pub struct RemoveFunctionStatement { pub name: Ident, } @@ -273,6 +276,7 @@ fn function(i: &str) -> IResult<&str, RemoveFunctionStatement> { // -------------------------------------------------- #[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)] +#[format(Named)] pub struct RemoveLoginStatement { pub name: Ident, pub base: Base, @@ -352,6 +356,7 @@ fn login(i: &str) -> IResult<&str, RemoveLoginStatement> { // -------------------------------------------------- #[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)] +#[format(Named)] pub struct RemoveTokenStatement { pub name: Ident, pub base: Base, @@ -446,6 +451,7 @@ fn token(i: &str) -> IResult<&str, RemoveTokenStatement> { // -------------------------------------------------- #[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)] +#[format(Named)] pub struct RemoveScopeStatement { pub name: Ident, } @@ -502,6 +508,7 @@ fn scope(i: &str) -> IResult<&str, RemoveScopeStatement> { // -------------------------------------------------- #[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)] +#[format(Named)] pub struct RemoveParamStatement { pub name: Ident, } @@ -556,6 +563,7 @@ fn param(i: &str) -> IResult<&str, RemoveParamStatement> { // -------------------------------------------------- #[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)] +#[format(Named)] pub struct RemoveTableStatement { pub name: Ident, } @@ -612,6 +620,7 @@ fn table(i: &str) -> IResult<&str, RemoveTableStatement> { // -------------------------------------------------- #[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)] +#[format(Named)] pub struct RemoveEventStatement { pub name: Ident, pub what: Ident, @@ -675,6 +684,7 @@ fn event(i: &str) -> IResult<&str, RemoveEventStatement> { // -------------------------------------------------- #[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)] +#[format(Named)] pub struct RemoveFieldStatement { pub name: Idiom, pub what: Ident, @@ -738,6 +748,7 @@ fn field(i: &str) -> IResult<&str, RemoveFieldStatement> { // -------------------------------------------------- #[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Store, Hash)] +#[format(Named)] pub struct RemoveIndexStatement { pub name: Ident, pub what: Ident,