Use custom serialization compaction for DEFINE and REMOVE statements
This commit is contained in:
parent
be42b3e7c9
commit
2895026593
5 changed files with 34 additions and 3 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -3882,9 +3882,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "surrealdb-derive"
|
||||
version = "0.6.0"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dfb39273220b1d4cd0936abb8d1e9ec0eb673e17044169cb4604345576b1e0ef"
|
||||
checksum = "0e0f2a75e22417f587cf23a5efa9f680f4002b8655b8481a01ee5e787f15d82b"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
|
|
|
@ -59,7 +59,7 @@ bigdecimal = { version = "0.3.0", features = ["serde", "string-only"] }
|
|||
bung = "0.1.0"
|
||||
channel = { version = "1.8.0", package = "async-channel" }
|
||||
chrono = { version = "0.4.24", features = ["serde"] }
|
||||
derive = { version = "0.6.0", package = "surrealdb-derive" }
|
||||
derive = { version = "0.7.0", package = "surrealdb-derive" }
|
||||
dmp = "0.1.3"
|
||||
echodb = { version = "0.4.0", optional = true }
|
||||
executor = { version = "1.5.0", package = "async-executor" }
|
||||
|
|
|
@ -41,6 +41,7 @@ use serde::{Deserialize, Serialize};
|
|||
use std::fmt::{self, Display, Write};
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Store, Hash)]
|
||||
#[format(Named)]
|
||||
pub enum DefineStatement {
|
||||
Namespace(DefineNamespaceStatement),
|
||||
Database(DefineDatabaseStatement),
|
||||
|
@ -1253,3 +1254,17 @@ fn index(i: &str) -> IResult<&str, DefineIndexStatement> {
|
|||
},
|
||||
))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn check_define_serialize() {
|
||||
let stm = DefineStatement::Namespace(DefineNamespaceStatement {
|
||||
name: Ident::from("test"),
|
||||
});
|
||||
assert_eq!(22, stm.to_vec().len());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ use serde::{Deserialize, Serialize};
|
|||
use std::fmt::{self, Display, Formatter};
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Store, Hash)]
|
||||
#[format(Named)]
|
||||
pub enum RemoveStatement {
|
||||
Namespace(RemoveNamespaceStatement),
|
||||
Database(RemoveDatabaseStatement),
|
||||
|
@ -798,3 +799,17 @@ fn index(i: &str) -> IResult<&str, RemoveIndexStatement> {
|
|||
},
|
||||
))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn check_remove_serialize() {
|
||||
let stm = RemoveStatement::Namespace(RemoveNamespaceStatement {
|
||||
name: Ident::from("test"),
|
||||
});
|
||||
assert_eq!(22, stm.to_vec().len());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,6 +99,7 @@ pub fn whats(i: &str) -> IResult<&str, Values> {
|
|||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq, PartialOrd, Deserialize, Store, Hash)]
|
||||
#[format(Compact)]
|
||||
pub enum Value {
|
||||
#[default]
|
||||
None,
|
||||
|
|
Loading…
Reference in a new issue