Info structure refactor (#3886)

Co-authored-by: Micha de Vries <micha@devrie.sh>
This commit is contained in:
Raphael Darley 2024-04-17 16:27:55 +02:00 committed by GitHub
parent 53ad2c5366
commit 4c8c9f6c8a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
143 changed files with 502 additions and 375 deletions

8
Cargo.lock generated
View file

@ -4702,9 +4702,9 @@ checksum = "4389f1d5789befaf6029ebd9f7dac4af7f7e3d61b69d4f30e2ac02b57e7712b0"
[[package]]
name = "revision"
version = "0.5.0"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87eb86913082f8976b06d07a59f17df9120e6f38b882cf3fc5a45b4499e224b6"
checksum = "588784c1d9453cfd2ce1b7aff06c903513677cf0e63779a0a3085ee8a44f5b17"
dependencies = [
"bincode",
"chrono",
@ -4720,9 +4720,9 @@ dependencies = [
[[package]]
name = "revision-derive"
version = "0.5.0"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf996fc5f61f1dbec35799b5c00c6dda12e8862e8cb782ed24e10d0292e60ed3"
checksum = "854ff0b6794d4e0aab5e4486870941caefe9f258e63cad2f21b49a6302377c85"
dependencies = [
"darling",
"proc-macro-error",

View file

@ -23,7 +23,13 @@ jwks = ["surrealdb/jwks"]
performance-profiler = ["dep:pprof"]
[workspace]
members = ["core", "lib", "lib/examples/actix", "lib/examples/axum", "lib/examples/rocket"]
members = [
"core",
"lib",
"lib/examples/actix",
"lib/examples/axum",
"lib/examples/rocket",
]
[profile.release]
lto = true
@ -44,10 +50,10 @@ base64 = "0.21.5"
bytes = "1.5.0"
ciborium = "0.2.1"
clap = { version = "4.4.11", features = [
"env",
"derive",
"wrap_help",
"unicode",
"env",
"derive",
"wrap_help",
"unicode",
] }
futures = "0.3.29"
futures-util = "0.3.29"
@ -62,15 +68,22 @@ opentelemetry = { version = "0.19", features = ["rt-tokio"] }
opentelemetry-otlp = { version = "0.12.0", features = ["metrics"] }
pin-project-lite = "0.2.13"
pprof = { version = "0.13.0", features = [
"flamegraph",
"prost-codec",
"flamegraph",
"prost-codec",
], optional = true }
rand = "0.8.5"
reqwest = { version = "0.11.22", default-features = false, features = [
"blocking",
"gzip",
"blocking",
"gzip",
] }
revision = { version = "0.7.0", features = [
"chrono",
"geo",
"roaring",
"regex",
"rust_decimal",
"uuid",
] }
revision = "0.5.0"
rmpv = "1.0.1"
rustyline = { version = "12.0.0", features = ["derive"] }
semver = "1.0.20"
@ -78,9 +91,9 @@ serde = { version = "1.0.193", features = ["derive"] }
serde_json = "1.0.108"
serde_pack = { version = "1.1.2", package = "rmp-serde" }
surrealdb = { version = "1", path = "lib", features = [
"protocol-http",
"protocol-ws",
"rustls",
"protocol-http",
"protocol-ws",
"rustls",
] }
tempfile = "3.8.1"
thiserror = "1.0.50"
@ -88,17 +101,17 @@ tokio = { version = "1.34.0", features = ["macros", "signal"] }
tokio-util = { version = "0.7.10", features = ["io"] }
tower = "0.4.13"
tower-http = { version = "0.4.4", features = [
"trace",
"sensitive-headers",
"auth",
"request-id",
"util",
"catch-panic",
"cors",
"set-header",
"limit",
"add-extension",
"compression-full",
"trace",
"sensitive-headers",
"auth",
"request-id",
"util",
"catch-panic",
"cors",
"set-header",
"limit",
"add-extension",
"compression-full",
] }
tracing = "0.1"
tracing-opentelemetry = "0.19.0"
@ -122,10 +135,10 @@ jemallocator = "0.5.4"
assert_fs = "1.0.13"
env_logger = "0.10.1"
opentelemetry-proto = { version = "0.2.0", features = [
"gen-tonic",
"traces",
"metrics",
"logs",
"gen-tonic",
"traces",
"metrics",
"logs",
] }
rcgen = "0.11.3"
serial_test = "2.0.0"
@ -149,16 +162,16 @@ depends = "$auto"
section = "utility"
priority = "optional"
assets = [
[
"target/release/surreal",
"usr/share/surrealdb/surreal",
"755",
],
[
"pkg/deb/README",
"usr/share/surrealdb/README",
"644",
],
[
"target/release/surreal",
"usr/share/surrealdb/surreal",
"755",
],
[
"pkg/deb/README",
"usr/share/surrealdb/README",
"644",
],
]
extended-description = "A scalable, distributed, collaborative, document-graph database, for the realtime web."
license-file = ["LICENSE", "4"]

View file

@ -11,11 +11,11 @@ repository = "https://github.com/surrealdb/surrealdb"
homepage = "https://github.com/surrealdb/surrealdb"
documentation = "https://docs.rs/surrealdb-core/"
keywords = [
"database",
"embedded-database",
"key-value",
"key-value-store",
"kv-store",
"database",
"embedded-database",
"key-value",
"key-value-store",
"kv-store",
]
categories = ["database-implementations", "data-structures", "embedded"]
license-file = "../LICENSE"
@ -43,11 +43,11 @@ http = ["dep:reqwest"]
ml = ["dep:surrealml", "dep:ndarray"]
jwks = ["dep:reqwest"]
arbitrary = [
"dep:arbitrary",
"dep:regex-syntax",
"rust_decimal/rust-fuzz",
"geo-types/arbitrary",
"uuid/arbitrary",
"dep:arbitrary",
"dep:regex-syntax",
"rust_decimal/rust-fuzz",
"geo-types/arbitrary",
"uuid/arbitrary",
]
# Private features
kv-fdb = ["tokio/time"]
@ -77,7 +77,7 @@ echodb = { version = "0.6.0", optional = true }
executor = { version = "1.8.0", package = "async-executor" }
ext-sort = { version = "^0.1.4", optional = true }
foundationdb = { version = "0.8.0", default-features = false, features = [
"embedded-fdb-include",
"embedded-fdb-include",
], optional = true }
fst = "0.4.7"
futures = "0.3.29"
@ -88,15 +88,15 @@ hex = { version = "0.4.3" }
indxdb = { version = "0.4.0", optional = true }
ipnet = "2.9.0"
js = { version = "0.5.1", package = "rquickjs", features = [
"array-buffer",
"bindgen",
"classes",
"futures",
"loader",
"macro",
"parallel",
"properties",
"rust-alloc",
"array-buffer",
"bindgen",
"classes",
"futures",
"loader",
"macro",
"parallel",
"properties",
"rust-alloc",
], optional = true }
jsonwebtoken = { version = "8.3.0-surreal.1", package = "surrealdb-jsonwebtoken" }
lexicmp = "0.1.0"
@ -117,11 +117,11 @@ reblessive = { version = "0.3.0" }
regex = "1.10.2"
regex-syntax = { version = "0.8.2", optional = true, features = ["arbitrary"] }
reqwest = { version = "0.11.22", default-features = false, features = [
"json",
"stream",
"multipart",
"json",
"stream",
"multipart",
], optional = true }
revision = "0.5.0"
revision = { version = "0.7.0", features = ["chrono", "geo", "roaring", "regex", "rust_decimal", "uuid"] }
roaring = { version = "0.10.2", features = ["serde"] }
rocksdb = { version = "0.21.0", features = ["lz4", "snappy"], optional = true }
rust_decimal = { version = "1.33.1", features = ["maths", "serde-str"] }
@ -162,25 +162,25 @@ wiremock = "0.5.22"
pharos = "0.5.3"
ring = { version = "0.17.7", features = ["wasm32_unknown_unknown_js"] }
tokio = { version = "1.34.0", default-features = false, features = [
"rt",
"sync",
"rt",
"sync",
] }
uuid = { version = "1.6.1", features = ["serde", "js", "v4", "v7"] }
wasm-bindgen-futures = "0.4.39"
wasmtimer = { version = "0.2.0", default-features = false, features = [
"tokio",
"tokio",
] }
ws_stream_wasm = "0.7.4"
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
tokio = { version = "1.34.0", default-features = false, features = [
"macros",
"io-util",
"io-std",
"fs",
"rt-multi-thread",
"time",
"sync",
"macros",
"io-util",
"io-std",
"fs",
"rt-multi-thread",
"time",
"sync",
] }
tokio-tungstenite = { version = "0.20.1", optional = true }
uuid = { version = "1.6.1", features = ["serde", "v4", "v7"] }

View file

@ -13,8 +13,8 @@ use std::collections::{BTreeMap, HashMap};
use std::fmt::{self, Display, Formatter};
// Mutation is a single mutation to a table.
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[revisioned(revision = 2)]
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[non_exhaustive]
pub enum TableMutation {
// Although the Value is supposed to contain a field "id" of Thing,
@ -42,8 +42,8 @@ impl From<DefineTableStatement> for Value {
}
}
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[non_exhaustive]
pub struct TableMutations(pub String, pub Vec<TableMutation>);
@ -53,8 +53,8 @@ impl TableMutations {
}
}
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[non_exhaustive]
pub struct DatabaseMutation(pub Vec<TableMutations>);
@ -71,8 +71,8 @@ impl Default for DatabaseMutation {
}
// Change is a set of mutations made to a table at the specific timestamp.
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[non_exhaustive]
pub struct ChangeSet(pub [u8; 10], pub DatabaseMutation);

View file

@ -8,8 +8,8 @@ use std::ops::{Add, Sub};
// NOTE: This is not a statement, but as per layering, keeping it here till we
// have a better structure.
#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize, PartialOrd, Hash, Store)]
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize, PartialOrd, Hash, Store)]
#[non_exhaustive]
pub struct ClusterMembership {
pub name: String,
@ -20,10 +20,10 @@ pub struct ClusterMembership {
// This struct is meant to represent a timestamp that can be used to partially order
// events in a cluster. It should be derived from a timestamp oracle, such as the
// one available in TiKV via the client `TimestampExt` implementation.
#[revisioned(revision = 1)]
#[derive(
Clone, Copy, Debug, Eq, PartialEq, Deserialize, Serialize, Ord, PartialOrd, Hash, Store, Default,
)]
#[revisioned(revision = 1)]
#[non_exhaustive]
pub struct Timestamp {
pub value: u64,
@ -39,8 +39,8 @@ impl From<u64> for Timestamp {
// This struct is to be used only when storing keys as the macro currently
// conflicts when you have Store and Key derive macros.
#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize, PartialOrd, Hash, Key)]
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize, PartialOrd, Hash, Key)]
#[non_exhaustive]
pub struct KeyTimestamp {
pub value: u64,

View file

@ -3,9 +3,9 @@ use revision::revisioned;
use serde::{Deserialize, Serialize};
use std::fmt::{self, Debug, Display};
#[revisioned(revision = 1)]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "UPPERCASE")]
#[revisioned(revision = 1)]
#[non_exhaustive]
pub enum Action {
Create,
@ -23,8 +23,8 @@ impl Display for Action {
}
}
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
#[revisioned(revision = 1)]
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
#[non_exhaustive]
pub struct Notification {
/// The id of the LIVE query to which this notification belongs

View file

@ -42,9 +42,9 @@ impl Response {
}
}
#[revisioned(revision = 1)]
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "UPPERCASE")]
#[revisioned(revision = 1)]
#[doc(hidden)]
#[non_exhaustive]
pub enum Status {
@ -73,8 +73,8 @@ impl Serialize for Response {
}
}
#[derive(Debug, Serialize, Deserialize)]
#[revisioned(revision = 1)]
#[derive(Debug, Serialize, Deserialize)]
#[doc(hidden)]
#[non_exhaustive]
pub struct QueryMethodResponse {

View file

@ -5,9 +5,9 @@ use serde::{Deserialize, Serialize};
use super::{is_allowed, Action, Actor, Error, Level, Resource, Role};
/// Specifies the current authentication for the datastore execution context.
#[revisioned(revision = 1)]
#[derive(Clone, Default, Debug, Eq, PartialEq, PartialOrd, Hash, Serialize, Deserialize)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[revisioned(revision = 1)]
#[non_exhaustive]
pub struct Auth {
actor: Actor,

View file

@ -13,9 +13,9 @@ use crate::sql::statements::{DefineTokenStatement, DefineUserStatement};
//
// User
//
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Hash, Serialize, Deserialize)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[revisioned(revision = 1)]
#[non_exhaustive]
pub struct Actor {
res: Resource,

View file

@ -7,9 +7,9 @@ use std::{
use cedar_policy::{Entity, EntityTypeName, EntityUid, RestrictedExpression};
use serde::{Deserialize, Serialize};
#[revisioned(revision = 1)]
#[derive(Clone, Default, Debug, Eq, PartialEq, PartialOrd, Deserialize, Serialize, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[revisioned(revision = 1)]
#[non_exhaustive]
pub enum Level {
#[default]

View file

@ -9,9 +9,9 @@ use super::Level;
use cedar_policy::{Entity, EntityId, EntityTypeName, EntityUid, RestrictedExpression};
use serde::{Deserialize, Serialize};
#[revisioned(revision = 1)]
#[derive(Clone, Default, Debug, Eq, PartialEq, PartialOrd, Hash, Serialize, Deserialize)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[revisioned(revision = 1)]
#[non_exhaustive]
pub enum ResourceKind {
#[default]
@ -79,9 +79,9 @@ impl ResourceKind {
}
}
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Hash, Serialize, Deserialize)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[revisioned(revision = 1)]
#[non_exhaustive]
pub struct Resource(String, ResourceKind, Level);

View file

@ -6,9 +6,9 @@ use serde::{Deserialize, Serialize};
use std::str::FromStr;
// In the future, we will allow for custom roles. For now, provide predefined roles.
#[revisioned(revision = 1)]
#[derive(Hash, Clone, Default, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[revisioned(revision = 1)]
#[non_exhaustive]
pub enum Role {
#[default]

View file

@ -149,8 +149,8 @@ impl DocIds {
}
}
#[derive(Serialize, Deserialize)]
#[revisioned(revision = 1)]
#[derive(Serialize, Deserialize)]
struct State {
btree: BState,
available_ids: Option<RoaringTreemap>,
@ -175,8 +175,8 @@ impl VersionedSerdeState for State {
}
}
#[derive(Serialize, Deserialize)]
#[revisioned(revision = 1)]
#[derive(Serialize, Deserialize)]
struct State1 {
btree: BState1,
available_ids: Option<RoaringTreemap>,
@ -195,8 +195,8 @@ impl From<State1> for State {
impl VersionedSerdeState for State1 {}
#[derive(Serialize, Deserialize)]
#[revisioned(revision = 1)]
#[derive(Serialize, Deserialize)]
struct State1skip {
btree: BState1skip,
available_ids: Option<RoaringTreemap>,

View file

@ -86,8 +86,8 @@ impl From<FtStatistics> for Value {
}
}
#[derive(Default, Serialize, Deserialize)]
#[revisioned(revision = 1)]
#[derive(Default, Serialize, Deserialize)]
struct State {
total_docs_lengths: u128,
doc_count: u64,

View file

@ -133,16 +133,16 @@ impl Terms {
}
}
#[derive(Serialize, Deserialize)]
#[revisioned(revision = 1)]
#[derive(Serialize, Deserialize)]
struct State {
btree: BState,
available_ids: Option<RoaringTreemap>,
next_term_id: TermId,
}
#[derive(Serialize, Deserialize)]
#[revisioned(revision = 1)]
#[derive(Serialize, Deserialize)]
struct State1 {
btree: BState1,
available_ids: Option<RoaringTreemap>,
@ -151,8 +151,8 @@ struct State1 {
impl VersionedSerdeState for State1 {}
#[derive(Serialize, Deserialize)]
#[revisioned(revision = 1)]
#[derive(Serialize, Deserialize)]
struct State1skip {
btree: BState1skip,
available_ids: Option<RoaringTreemap>,

View file

@ -28,8 +28,8 @@ where
bk: PhantomData<BK>,
}
#[derive(Clone, Serialize, Deserialize)]
#[revisioned(revision = 2)]
#[derive(Clone, Serialize, Deserialize)]
#[non_exhaustive]
pub struct BState {
minimum_degree: u32,
@ -57,16 +57,16 @@ impl VersionedSerdeState for BState {
}
}
#[derive(Clone, Serialize, Deserialize)]
#[revisioned(revision = 1)]
#[derive(Clone, Serialize, Deserialize)]
pub(in crate::idx) struct BState1 {
minimum_degree: u32,
root: Option<NodeId>,
next_node_id: NodeId,
}
#[derive(Clone, Serialize, Deserialize)]
#[revisioned(revision = 1)]
#[derive(Clone, Serialize, Deserialize)]
pub(in crate::idx) struct BState1skip {
minimum_degree: u32,
root: Option<NodeId>,

View file

@ -1550,8 +1550,8 @@ impl From<MtStatistics> for Value {
}
}
#[derive(Clone, Serialize, Deserialize)]
#[revisioned(revision = 2)]
#[derive(Clone, Serialize, Deserialize)]
#[non_exhaustive]
pub struct MState {
capacity: u16,

View file

@ -9,8 +9,8 @@ use std::ops::Mul;
use std::sync::Arc;
/// In the context of a Symmetric MTree index, the term object refers to a vector, representing the indexed item.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[revisioned(revision = 1)]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[non_exhaustive]
pub enum Vector {
F64(Vec<f64>),

View file

@ -8,8 +8,8 @@ use serde::Serialize;
/// The data returned by the database
// The variants here should be in exactly the same order as `crate::engine::remote::ws::Data`
// In future, they will possibly be merged to avoid having to keep them in sync.
#[derive(Debug, Serialize)]
#[revisioned(revision = 1)]
#[derive(Debug, Serialize)]
#[non_exhaustive]
pub enum Data {
/// Generally methods return a `sql::Value`

View file

@ -4,9 +4,9 @@ use revision::revisioned;
use serde::{Deserialize, Serialize};
use std::fmt;
#[revisioned(revision = 1)]
#[derive(Clone, Copy, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[revisioned(revision = 1)]
#[non_exhaustive]
pub enum Algorithm {
EdDSA,

View file

@ -16,9 +16,9 @@ use std::ops::DerefMut;
pub(crate) const TOKEN: &str = "$surrealdb::private::sql::Array";
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Default, Eq, Ord, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[serde(rename = "$surrealdb::private::sql::Array")]
#[revisioned(revision = 1)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[non_exhaustive]
pub struct Array(pub Vec<Value>);

View file

@ -4,9 +4,9 @@ use revision::revisioned;
use serde::{Deserialize, Serialize};
use std::fmt;
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[revisioned(revision = 1)]
#[non_exhaustive]
pub enum Base {
Root,

View file

@ -18,9 +18,9 @@ use std::ops::Deref;
pub(crate) const TOKEN: &str = "$surrealdb::private::sql::Block";
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[serde(rename = "$surrealdb::private::sql::Block")]
#[revisioned(revision = 1)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[non_exhaustive]
pub struct Block(pub Vec<Entry>);
@ -172,8 +172,9 @@ impl InfoStructure for Block {
self.to_string().into()
}
}
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Hash)]
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[non_exhaustive]
pub enum Entry {

View file

@ -7,8 +7,8 @@ use serde::{
use std::fmt::{self, Display, Formatter};
use std::ops::Deref;
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Hash)]
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[non_exhaustive]
pub struct Bytes(pub(crate) Vec<u8>);

View file

@ -11,9 +11,9 @@ use std::fmt;
pub(crate) const TOKEN: &str = "$surrealdb::private::sql::Cast";
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Hash)]
#[serde(rename = "$surrealdb::private::sql::Cast")]
#[revisioned(revision = 1)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[non_exhaustive]
pub struct Cast(pub Kind, pub Value);

View file

@ -2,9 +2,9 @@ use revision::revisioned;
use serde::{Deserialize, Serialize};
use std::fmt;
#[revisioned(revision = 1)]
#[derive(Clone, Copy, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[revisioned(revision = 1)]
/// ChangeFeedInclude statements are an appendix
#[non_exhaustive]
pub enum ChangeFeedInclude {

View file

@ -7,8 +7,8 @@ use std::fmt::{self, Display, Formatter};
use std::str;
use std::time;
#[derive(Clone, Copy, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[revisioned(revision = 2)]
#[derive(Clone, Copy, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[non_exhaustive]
pub struct ChangeFeed {
pub expiry: time::Duration,

View file

@ -5,8 +5,8 @@ use serde::{Deserialize, Serialize};
use std::fmt;
use std::ops::Deref;
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[non_exhaustive]
pub struct Cond(pub Value);

View file

@ -13,9 +13,9 @@ use std::fmt;
pub(crate) const TOKEN: &str = "$surrealdb::private::sql::Constant";
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[serde(rename = "$surrealdb::private::sql::Constant")]
#[revisioned(revision = 1)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[non_exhaustive]
pub enum Constant {

View file

@ -9,8 +9,8 @@ use revision::revisioned;
use serde::{Deserialize, Serialize};
use std::fmt::{self, Display, Formatter};
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[non_exhaustive]
pub enum Data {

View file

@ -14,9 +14,9 @@ use super::escape::quote_str;
pub(crate) const TOKEN: &str = "$surrealdb::private::sql::Datetime";
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord, Serialize, Deserialize, Hash)]
#[serde(rename = "$surrealdb::private::sql::Datetime")]
#[revisioned(revision = 1)]
#[non_exhaustive]
pub struct Datetime(pub DateTime<Utc>);

View file

@ -2,8 +2,8 @@ use revision::revisioned;
use serde::{Deserialize, Serialize};
use std::fmt;
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[non_exhaustive]
pub enum Dir {

View file

@ -20,9 +20,9 @@ pub(crate) static NANOSECONDS_PER_MICROSECOND: u32 = 1000;
pub(crate) const TOKEN: &str = "$surrealdb::private::sql::Duration";
#[revisioned(revision = 1)]
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[serde(rename = "$surrealdb::private::sql::Duration")]
#[revisioned(revision = 1)]
#[non_exhaustive]
pub struct Duration(pub time::Duration);

View file

@ -7,10 +7,10 @@ use std::fmt;
pub(crate) const TOKEN: &str = "$surrealdb::private::sql::Edges";
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[serde(rename = "$surrealdb::private::sql::Edges")]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[revisioned(revision = 1)]
#[non_exhaustive]
pub struct Edges {
pub dir: Dir,

View file

@ -2,8 +2,8 @@ use revision::revisioned;
use serde::{Deserialize, Serialize};
use std::fmt;
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[non_exhaustive]
pub struct Explain(pub bool);

View file

@ -13,9 +13,9 @@ use std::str;
pub(crate) const TOKEN: &str = "$surrealdb::private::sql::Expression";
/// Binary expressions.
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[serde(rename = "$surrealdb::private::sql::Expression")]
#[revisioned(revision = 1)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[non_exhaustive]
pub enum Expression {

View file

@ -7,8 +7,8 @@ use serde::{Deserialize, Serialize};
use std::fmt::{self, Display, Formatter};
use std::ops::Deref;
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[non_exhaustive]
pub struct Fetchs(pub Vec<Fetch>);
@ -39,8 +39,9 @@ impl InfoStructure for Fetchs {
Value::Array(self.0.into_iter().map(|f| f.0.structure()).collect())
}
}
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[non_exhaustive]
pub struct Fetch(pub Idiom);

View file

@ -11,8 +11,8 @@ use std::borrow::Cow;
use std::fmt::{self, Display, Formatter, Write};
use std::ops::Deref;
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[non_exhaustive]
pub struct Fields(pub Vec<Field>, pub bool);
@ -242,8 +242,8 @@ impl Fields {
}
}
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[non_exhaustive]
pub enum Field {

View file

@ -4,9 +4,9 @@ use serde::{Deserialize, Serialize};
use std::fmt;
use std::fmt::Display;
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[revisioned(revision = 1)]
#[non_exhaustive]
pub enum Filter {
Ascii,

View file

@ -20,9 +20,9 @@ use super::Kind;
pub(crate) const TOKEN: &str = "$surrealdb::private::sql::Function";
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Hash)]
#[serde(rename = "$surrealdb::private::sql::Function")]
#[revisioned(revision = 1)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[non_exhaustive]
pub enum Function {

View file

@ -10,9 +10,9 @@ use std::fmt;
pub(crate) const TOKEN: &str = "$surrealdb::private::sql::Future";
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[serde(rename = "$surrealdb::private::sql::Future")]
#[revisioned(revision = 1)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[non_exhaustive]
pub struct Future(pub Block);

View file

@ -15,10 +15,10 @@ use std::{fmt, hash};
pub(crate) const TOKEN: &str = "$surrealdb::private::sql::Geometry";
#[revisioned(revision = 1)]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(rename = "$surrealdb::private::sql::Geometry")]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[revisioned(revision = 1)]
#[non_exhaustive]
pub enum Geometry {
Point(Point<f64>),

View file

@ -12,8 +12,8 @@ use revision::revisioned;
use serde::{Deserialize, Serialize};
use std::fmt::{self, Display, Formatter, Write};
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[non_exhaustive]
pub struct Graph {

View file

@ -5,8 +5,8 @@ use serde::{Deserialize, Serialize};
use std::fmt::{self, Display, Formatter};
use std::ops::Deref;
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[non_exhaustive]
pub struct Groups(pub Vec<Group>);
@ -36,8 +36,8 @@ impl Display for Groups {
}
}
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[non_exhaustive]
pub struct Group(pub Idiom);

View file

@ -11,8 +11,8 @@ use std::collections::BTreeMap;
use std::fmt::{self, Display, Formatter};
use ulid::Ulid;
#[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Serialize, Deserialize, Hash)]
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Serialize, Deserialize, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[non_exhaustive]
pub enum Gen {
@ -21,8 +21,8 @@ pub enum Gen {
Uuid,
}
#[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Serialize, Deserialize, Hash)]
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Serialize, Deserialize, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[non_exhaustive]
pub enum Id {

View file

@ -6,8 +6,8 @@ use std::fmt::{self, Display, Formatter};
use std::ops::Deref;
use std::str;
#[derive(Clone, Debug, Default, Eq, Ord, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Default, Eq, Ord, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[non_exhaustive]
pub struct Ident(#[serde(with = "no_nul_bytes")] pub String);

View file

@ -18,8 +18,8 @@ use std::str;
pub(crate) const TOKEN: &str = "$surrealdb::private::sql::Idiom";
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[non_exhaustive]
pub struct Idioms(pub Vec<Idiom>);
@ -45,9 +45,9 @@ impl Display for Idioms {
}
}
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[serde(rename = "$surrealdb::private::sql::Idiom")]
#[revisioned(revision = 1)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[non_exhaustive]
pub struct Idiom(pub Vec<Part>);

View file

@ -12,9 +12,9 @@ use serde::{Deserialize, Serialize};
use std::fmt;
use std::fmt::{Display, Formatter};
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[revisioned(revision = 1)]
#[non_exhaustive]
pub enum Index {
/// (Basic) non unique
@ -28,9 +28,9 @@ pub enum Index {
MTree(MTreeParams),
}
#[revisioned(revision = 2)]
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[revisioned(revision = 2)]
#[non_exhaustive]
pub struct SearchParams {
pub az: Ident,
@ -50,9 +50,9 @@ pub struct SearchParams {
pub terms_cache: u32,
}
#[revisioned(revision = 2)]
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[revisioned(revision = 2)]
#[non_exhaustive]
pub struct MTreeParams {
pub dimension: u16,
@ -86,9 +86,9 @@ impl MTreeParams {
}
}
#[revisioned(revision = 1)]
#[derive(Clone, Default, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[revisioned(revision = 1)]
#[non_exhaustive]
pub enum Distance1 {
#[default]
@ -99,9 +99,9 @@ pub enum Distance1 {
Minkowski(Number),
}
#[revisioned(revision = 1)]
#[derive(Clone, Default, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[revisioned(revision = 1)]
#[non_exhaustive]
pub enum Distance {
Chebyshev,
@ -145,9 +145,9 @@ impl Display for Distance {
}
}
#[revisioned(revision = 1)]
#[derive(Clone, Copy, Default, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[revisioned(revision = 1)]
#[non_exhaustive]
pub enum VectorType {
#[default]

View file

@ -4,9 +4,9 @@ use revision::revisioned;
use serde::{Deserialize, Serialize};
use std::fmt::{self, Display, Formatter};
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[revisioned(revision = 1)]
#[non_exhaustive]
pub enum Kind {
Any,

View file

@ -3,9 +3,9 @@ use serde::{Deserialize, Serialize};
use std::fmt;
use std::fmt::Display;
#[revisioned(revision = 1)]
#[derive(Clone, Copy, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[revisioned(revision = 1)]
#[non_exhaustive]
pub enum Language {
Arabic,

View file

@ -8,8 +8,8 @@ use revision::revisioned;
use serde::{Deserialize, Serialize};
use std::fmt;
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[non_exhaustive]
pub struct Limit(pub Value);

View file

@ -44,9 +44,9 @@ impl Iterator for IntoIter {
}
}
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[serde(rename = "$surrealdb::private::sql::Mock")]
#[revisioned(revision = 1)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[non_exhaustive]
pub enum Mock {

View file

@ -26,9 +26,9 @@ use std::collections::HashMap;
#[cfg(feature = "ml")]
const ARGUMENTS: &str = "The model expects 1 argument. The argument can be either a number, an object, or an array of numbers.";
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Default, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[revisioned(revision = 1)]
#[non_exhaustive]
pub struct Model {
pub name: String,

View file

@ -13,9 +13,9 @@ use std::ops::{self, Add, Div, Mul, Neg, Rem, Sub};
pub(crate) const TOKEN: &str = "$surrealdb::private::sql::Number";
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(rename = "$surrealdb::private::sql::Number")]
#[revisioned(revision = 1)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[non_exhaustive]
pub enum Number {

View file

@ -18,9 +18,9 @@ use std::ops::DerefMut;
pub(crate) const TOKEN: &str = "$surrealdb::private::sql::Object";
/// Invariant: Keys never contain NUL bytes.
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Default, Eq, Ord, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[serde(rename = "$surrealdb::private::sql::Object")]
#[revisioned(revision = 1)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[non_exhaustive]
pub struct Object(#[serde(with = "no_nul_bytes_in_keys")] pub BTreeMap<String, Value>);

View file

@ -3,10 +3,10 @@ use crate::sql::value::Value;
use revision::revisioned;
use serde::{Deserialize, Serialize};
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[serde(tag = "op")]
#[serde(rename_all = "lowercase")]
#[revisioned(revision = 1)]
#[non_exhaustive]
pub enum Operation {
Add {

View file

@ -6,8 +6,8 @@ use std::fmt;
use std::fmt::Write;
/// Binary operators.
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[non_exhaustive]
pub enum Operator {

View file

@ -7,8 +7,8 @@ use std::cmp::Ordering;
use std::fmt;
use std::ops::Deref;
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[non_exhaustive]
pub struct Orders(pub Vec<Order>);
@ -61,8 +61,8 @@ impl fmt::Display for Orders {
}
}
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[non_exhaustive]
pub struct Order {

View file

@ -3,8 +3,8 @@ use revision::revisioned;
use serde::{Deserialize, Serialize};
use std::fmt::{self, Display};
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[non_exhaustive]
pub enum Output {

View file

@ -12,10 +12,10 @@ use std::{fmt, ops::Deref, str};
pub(crate) const TOKEN: &str = "$surrealdb::private::sql::Param";
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[serde(rename = "$surrealdb::private::sql::Param")]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[revisioned(revision = 1)]
#[non_exhaustive]
pub struct Param(pub Ident);

View file

@ -4,8 +4,8 @@ use serde::{Deserialize, Serialize};
use std::fmt;
use std::str;
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[non_exhaustive]
pub enum Part {

View file

@ -9,9 +9,9 @@ use std::fmt::Write;
use std::fmt::{self, Display, Formatter};
use std::str;
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[revisioned(revision = 1)]
#[non_exhaustive]
pub struct Permissions {
pub select: Permission,
@ -132,9 +132,9 @@ impl PermissionKind {
}
}
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[revisioned(revision = 1)]
#[non_exhaustive]
pub enum Permission {
None,

View file

@ -11,8 +11,8 @@ use std::str;
pub(crate) const TOKEN: &str = "$surrealdb::private::sql::Query";
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[serde(rename = "$surrealdb::private::sql::Query")]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[non_exhaustive]

View file

@ -21,10 +21,10 @@ use std::str::FromStr;
const ID: &str = "id";
pub(crate) const TOKEN: &str = "$surrealdb::private::sql::Range";
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Hash)]
#[serde(rename = "$surrealdb::private::sql::Range")]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[revisioned(revision = 1)]
#[non_exhaustive]
pub struct Range {
#[serde(with = "no_nul_bytes")]

View file

@ -15,8 +15,8 @@ use std::{env, str};
pub(crate) const TOKEN: &str = "$surrealdb::private::sql::Regex";
#[derive(Clone)]
#[revisioned(revision = 1)]
#[derive(Clone)]
#[non_exhaustive]
pub struct Regex(pub regex::Regex);

View file

@ -3,9 +3,9 @@ use serde::{Deserialize, Serialize};
use std::fmt;
use std::hash::{Hash, Hasher};
#[revisioned(revision = 1)]
#[derive(Clone, Debug, PartialOrd, Serialize, Deserialize)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[revisioned(revision = 1)]
#[non_exhaustive]
pub enum Scoring {
Bm {

View file

@ -5,8 +5,8 @@ use std::fmt::{self, Display, Formatter};
use std::ops::Deref;
use std::str;
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[non_exhaustive]
pub struct Script(#[serde(with = "no_nul_bytes")] pub String);

View file

@ -5,8 +5,8 @@ use serde::{Deserialize, Serialize};
use std::fmt::{self, Display, Formatter};
use std::ops::Deref;
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[non_exhaustive]
pub struct Splits(pub Vec<Split>);
@ -32,8 +32,8 @@ impl fmt::Display for Splits {
}
}
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[non_exhaustive]
pub struct Split(pub Idiom);

View file

@ -8,8 +8,8 @@ use revision::revisioned;
use serde::{Deserialize, Serialize};
use std::fmt;
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[non_exhaustive]
pub struct Start(pub Value);

View file

@ -22,9 +22,9 @@ use std::{
time::Duration,
};
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[revisioned(revision = 1)]
#[non_exhaustive]
pub struct Statements(pub Vec<Statement>);
@ -52,9 +52,9 @@ impl Display for Statements {
}
}
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[revisioned(revision = 1)]
#[non_exhaustive]
pub enum Statement {
Value(Value),

View file

@ -18,8 +18,8 @@ use serde::{Deserialize, Serialize};
use std::fmt;
use std::fmt::{Display, Formatter};
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[non_exhaustive]
pub enum AnalyzeStatement {

View file

@ -3,8 +3,8 @@ use revision::revisioned;
use serde::{Deserialize, Serialize};
use std::fmt;
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[non_exhaustive]
pub struct BeginStatement;

View file

@ -8,8 +8,8 @@ use revision::revisioned;
use serde::{Deserialize, Serialize};
use std::fmt;
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[non_exhaustive]
pub struct BreakStatement;

View file

@ -3,8 +3,8 @@ use revision::revisioned;
use serde::{Deserialize, Serialize};
use std::fmt;
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[non_exhaustive]
pub struct CancelStatement;

View file

@ -3,9 +3,9 @@ use revision::revisioned;
use serde::{Deserialize, Serialize};
use std::fmt;
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[revisioned(revision = 1)]
#[non_exhaustive]
pub struct CommitStatement;

View file

@ -8,8 +8,8 @@ use revision::revisioned;
use serde::{Deserialize, Serialize};
use std::fmt;
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[non_exhaustive]
pub struct ContinueStatement;

View file

@ -8,8 +8,8 @@ use revision::revisioned;
use serde::{Deserialize, Serialize};
use std::fmt;
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[revisioned(revision = 2)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[non_exhaustive]
pub struct CreateStatement {

View file

@ -10,9 +10,9 @@ use revision::revisioned;
use serde::{Deserialize, Serialize};
use std::fmt::{self, Display};
#[revisioned(revision = 3)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[revisioned(revision = 3)]
#[non_exhaustive]
pub struct DefineAnalyzerStatement {
pub name: Ident,

View file

@ -10,9 +10,9 @@ use revision::revisioned;
use serde::{Deserialize, Serialize};
use std::fmt::{self, Display};
#[revisioned(revision = 2)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[revisioned(revision = 2)]
#[non_exhaustive]
pub struct DefineDatabaseStatement {
pub id: Option<u32>,

View file

@ -10,9 +10,9 @@ use revision::revisioned;
use serde::{Deserialize, Serialize};
use std::fmt::{self, Display};
#[revisioned(revision = 2)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[revisioned(revision = 2)]
#[non_exhaustive]
pub struct DefineEventStatement {
pub name: Ident,

View file

@ -15,9 +15,9 @@ use revision::revisioned;
use serde::{Deserialize, Serialize};
use std::fmt::{self, Display, Write};
#[revisioned(revision = 3)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[revisioned(revision = 3)]
#[non_exhaustive]
pub struct DefineFieldStatement {
pub name: Idiom,

View file

@ -13,9 +13,9 @@ use revision::revisioned;
use serde::{Deserialize, Serialize};
use std::fmt::{self, Display, Write};
#[revisioned(revision = 2)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[revisioned(revision = 2)]
#[non_exhaustive]
pub struct DefineFunctionStatement {
pub name: Ident,

View file

@ -13,9 +13,9 @@ use serde::{Deserialize, Serialize};
use std::fmt::{self, Display};
use std::sync::Arc;
#[revisioned(revision = 2)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[revisioned(revision = 2)]
#[non_exhaustive]
pub struct DefineIndexStatement {
pub name: Ident,

View file

@ -37,9 +37,9 @@ use revision::revisioned;
use serde::{Deserialize, Serialize};
use std::fmt::{self, Display};
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[revisioned(revision = 1)]
#[non_exhaustive]
pub enum DefineStatement {
Namespace(DefineNamespaceStatement),

View file

@ -13,9 +13,9 @@ use revision::revisioned;
use serde::{Deserialize, Serialize};
use std::fmt::{self, Write};
#[revisioned(revision = 2)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[revisioned(revision = 2)]
#[non_exhaustive]
pub struct DefineModelStatement {
pub hash: String,

View file

@ -10,9 +10,9 @@ use revision::revisioned;
use serde::{Deserialize, Serialize};
use std::fmt::{self, Display};
#[revisioned(revision = 2)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[revisioned(revision = 2)]
#[non_exhaustive]
pub struct DefineNamespaceStatement {
pub id: Option<u32>,

View file

@ -11,9 +11,9 @@ use revision::revisioned;
use serde::{Deserialize, Serialize};
use std::fmt::{self, Display, Write};
#[revisioned(revision = 2)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[revisioned(revision = 2)]
#[non_exhaustive]
pub struct DefineParamStatement {
pub name: Ident,

View file

@ -12,9 +12,9 @@ use revision::revisioned;
use serde::{Deserialize, Serialize};
use std::fmt::{self, Display};
#[revisioned(revision = 2)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[revisioned(revision = 2)]
#[non_exhaustive]
pub struct DefineScopeStatement {
pub name: Ident,

View file

@ -20,9 +20,9 @@ use std::fmt::{self, Display, Write};
use super::DefineFieldStatement;
#[revisioned(revision = 3)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[revisioned(revision = 3)]
#[non_exhaustive]
pub struct DefineTableStatement {
pub id: Option<u32>,

View file

@ -10,9 +10,9 @@ use revision::revisioned;
use serde::{Deserialize, Serialize};
use std::fmt::{self, Display};
#[revisioned(revision = 2)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[revisioned(revision = 2)]
#[non_exhaustive]
pub struct DefineTokenStatement {
pub name: Ident,

View file

@ -15,9 +15,9 @@ use revision::revisioned;
use serde::{Deserialize, Serialize};
use std::fmt::{self, Display};
#[revisioned(revision = 2)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[revisioned(revision = 2)]
#[non_exhaustive]
pub struct DefineUserStatement {
pub name: Ident,
@ -206,7 +206,7 @@ impl InfoStructure for DefineUserStatement {
let Self {
name,
base,
code,
hash,
roles,
comment,
..
@ -217,7 +217,7 @@ impl InfoStructure for DefineUserStatement {
acc.insert("base".to_string(), base.structure());
acc.insert("code".to_string(), code.into());
acc.insert("passhash".to_string(), hash.into());
acc.insert(
"roles".to_string(),

View file

@ -8,9 +8,9 @@ use revision::revisioned;
use serde::{Deserialize, Serialize};
use std::fmt;
#[revisioned(revision = 2)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[revisioned(revision = 2)]
#[non_exhaustive]
pub struct DeleteStatement {
#[revision(start = 2)]

View file

@ -9,9 +9,9 @@ use revision::revisioned;
use serde::{Deserialize, Serialize};
use std::fmt::{self, Display};
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[revisioned(revision = 1)]
#[non_exhaustive]
pub struct ForeachStatement {
pub param: Param,

View file

@ -9,8 +9,8 @@ use revision::revisioned;
use serde::{Deserialize, Serialize};
use std::fmt::{self, Display, Write};
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[non_exhaustive]
pub struct IfelseStatement {

View file

@ -10,22 +10,64 @@ use revision::revisioned;
use serde::{Deserialize, Serialize};
use std::fmt;
#[revisioned(revision = 2)]
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[revisioned(revision = 1)]
#[non_exhaustive]
pub enum InfoStatement {
#[revision(end = 2, convert_fn = "root_migrate")]
Root,
#[revision(start = 2)]
Root(bool),
#[revision(end = 2, convert_fn = "ns_migrate")]
Ns,
#[revision(start = 2)]
Ns(bool),
#[revision(end = 2, convert_fn = "db_migrate")]
Db,
#[revision(start = 2)]
Db(bool),
#[revision(end = 2, convert_fn = "sc_migrate")]
Sc(Ident),
#[revision(start = 2)]
Sc(Ident, bool),
#[revision(end = 2, convert_fn = "tb_migrate")]
Tb(Ident),
#[revision(start = 2)]
Tb(Ident, bool),
#[revision(end = 2, convert_fn = "user_migrate")]
User(Ident, Option<Base>),
RootStructure,
NsStructure,
DbStructure,
ScStructure(Ident),
TbStructure(Ident),
#[revision(start = 2)]
User(Ident, Option<Base>, bool),
}
impl InfoStatement {
fn root_migrate(_revision: u16, _: ()) -> Result<Self, revision::Error> {
Ok(Self::Root(false))
}
fn ns_migrate(_revision: u16, _: ()) -> Result<Self, revision::Error> {
Ok(Self::Ns(false))
}
fn db_migrate(_revision: u16, _: ()) -> Result<Self, revision::Error> {
Ok(Self::Db(false))
}
fn sc_migrate(_revision: u16, i: (Ident,)) -> Result<Self, revision::Error> {
Ok(Self::Sc(i.0, false))
}
fn tb_migrate(_revision: u16, n: (Ident,)) -> Result<Self, revision::Error> {
Ok(Self::Tb(n.0, false))
}
fn user_migrate(
_revision: u16,
(i, b): (Ident, Option<Base>),
) -> Result<Self, revision::Error> {
Ok(Self::User(i, b, false))
}
}
impl InfoStatement {
@ -39,7 +81,7 @@ impl InfoStatement {
) -> Result<Value, Error> {
// Allowed to run?
match self {
InfoStatement::Root => {
InfoStatement::Root(false) => {
// Allowed to run?
opt.is_allowed(Action::View, ResourceKind::Any, &Base::Root)?;
// Claim transaction
@ -61,7 +103,7 @@ impl InfoStatement {
// Ok all good
Value::from(res).ok()
}
InfoStatement::Ns => {
InfoStatement::Ns(false) => {
// Allowed to run?
opt.is_allowed(Action::View, ResourceKind::Any, &Base::Ns)?;
// Claim transaction
@ -89,7 +131,7 @@ impl InfoStatement {
// Ok all good
Value::from(res).ok()
}
InfoStatement::Db => {
InfoStatement::Db(false) => {
// Allowed to run?
opt.is_allowed(Action::View, ResourceKind::Any, &Base::Db)?;
// Claim transaction
@ -147,7 +189,7 @@ impl InfoStatement {
// Ok all good
Value::from(res).ok()
}
InfoStatement::Sc(sc) => {
InfoStatement::Sc(sc, false) => {
// Allowed to run?
opt.is_allowed(Action::View, ResourceKind::Any, &Base::Db)?;
// Claim transaction
@ -163,7 +205,7 @@ impl InfoStatement {
// Ok all good
Value::from(res).ok()
}
InfoStatement::Tb(tb) => {
InfoStatement::Tb(tb, false) => {
// Allowed to run?
opt.is_allowed(Action::View, ResourceKind::Any, &Base::Db)?;
// Claim transaction
@ -203,7 +245,7 @@ impl InfoStatement {
// Ok all good
Value::from(res).ok()
}
InfoStatement::User(user, base) => {
InfoStatement::User(user, base, false) => {
let base = base.clone().unwrap_or(opt.selected_base()?);
// Allowed to run?
opt.is_allowed(Action::View, ResourceKind::Actor, &base)?;
@ -220,7 +262,7 @@ impl InfoStatement {
// Ok all good
Value::from(res.to_string()).ok()
}
InfoStatement::RootStructure => {
InfoStatement::Root(true) => {
// Allowed to run?
opt.is_allowed(Action::View, ResourceKind::Any, &Base::Root)?;
// Claim transaction
@ -234,7 +276,7 @@ impl InfoStatement {
// Ok all good
Value::from(res).ok()
}
InfoStatement::NsStructure => {
InfoStatement::Ns(true) => {
// Allowed to run?
opt.is_allowed(Action::View, ResourceKind::Any, &Base::Ns)?;
// Claim transaction
@ -250,7 +292,7 @@ impl InfoStatement {
// Ok all good
Value::from(res).ok()
}
InfoStatement::DbStructure => {
InfoStatement::Db(true) => {
// Allowed to run?
opt.is_allowed(Action::View, ResourceKind::Any, &Base::Db)?;
// Claim transaction
@ -294,7 +336,7 @@ impl InfoStatement {
// Ok all good
Value::from(res).ok()
}
InfoStatement::ScStructure(sc) => {
InfoStatement::Sc(sc, true) => {
// Allowed to run?
opt.is_allowed(Action::View, ResourceKind::Any, &Base::Db)?;
// Claim transaction
@ -309,7 +351,7 @@ impl InfoStatement {
// Ok all good
Value::from(res).ok()
}
InfoStatement::TbStructure(tb) => {
InfoStatement::Tb(tb, true) => {
// Allowed to run?
opt.is_allowed(Action::View, ResourceKind::Any, &Base::Db)?;
// Claim transaction
@ -344,6 +386,23 @@ impl InfoStatement {
// Ok all good
Value::from(res).ok()
}
InfoStatement::User(user, base, true) => {
let base = base.clone().unwrap_or(opt.selected_base()?);
// Allowed to run?
opt.is_allowed(Action::View, ResourceKind::Actor, &base)?;
// Claim transaction
let mut run = txn.lock().await;
// Process the user
let res = match base {
Base::Root => run.get_root_user(user).await?,
Base::Ns => run.get_ns_user(opt.ns(), user).await?,
Base::Db => run.get_db_user(opt.ns(), opt.db(), user).await?,
_ => return Err(Error::InvalidLevel(base.to_string())),
};
// Ok all good
Ok(res.structure())
}
}
}
}
@ -351,20 +410,24 @@ impl InfoStatement {
impl fmt::Display for InfoStatement {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
Self::Root => f.write_str("INFO FOR ROOT"),
Self::RootStructure => f.write_str("INFO FOR ROOT STRUCTURE"),
Self::Ns => f.write_str("INFO FOR NAMESPACE"),
Self::NsStructure => f.write_str("INFO FOR NAMESPACE STRUCTURE"),
Self::Db => f.write_str("INFO FOR DATABASE"),
Self::DbStructure => f.write_str("INFO FOR DATABASE STRUCTURE"),
Self::Sc(ref s) => write!(f, "INFO FOR SCOPE {s}"),
Self::ScStructure(ref s) => write!(f, "INFO FOR SCOPE {s} STRUCTURE"),
Self::Tb(ref t) => write!(f, "INFO FOR TABLE {t}"),
Self::TbStructure(ref t) => write!(f, "INFO FOR TABLE {t} STRUCTURE"),
Self::User(ref u, ref b) => match b {
Self::Root(false) => f.write_str("INFO FOR ROOT"),
Self::Root(true) => f.write_str("INFO FOR ROOT STRUCTURE"),
Self::Ns(false) => f.write_str("INFO FOR NAMESPACE"),
Self::Ns(true) => f.write_str("INFO FOR NAMESPACE STRUCTURE"),
Self::Db(false) => f.write_str("INFO FOR DATABASE"),
Self::Db(true) => f.write_str("INFO FOR DATABASE STRUCTURE"),
Self::Sc(ref s, false) => write!(f, "INFO FOR SCOPE {s}"),
Self::Sc(ref s, true) => write!(f, "INFO FOR SCOPE {s} STRUCTURE"),
Self::Tb(ref t, false) => write!(f, "INFO FOR TABLE {t}"),
Self::Tb(ref t, true) => write!(f, "INFO FOR TABLE {t} STRUCTURE"),
Self::User(ref u, ref b, false) => match b {
Some(ref b) => write!(f, "INFO FOR USER {u} ON {b}"),
None => write!(f, "INFO FOR USER {u}"),
},
Self::User(ref u, ref b, true) => match b {
Some(ref b) => write!(f, "INFO FOR USER {u} ON {b} STRUCTURE"),
None => write!(f, "INFO FOR USER {u} STRUCTURE"),
},
}
}
}
@ -376,16 +439,15 @@ pub(crate) trait InfoStructure {
}
impl InfoStatement {
pub(crate) fn structurize(self) -> Result<Self, ()> {
let out = match self {
InfoStatement::Root => InfoStatement::RootStructure,
InfoStatement::Ns => InfoStatement::NsStructure,
InfoStatement::Db => InfoStatement::DbStructure,
InfoStatement::Sc(s) => InfoStatement::ScStructure(s),
InfoStatement::Tb(t) => InfoStatement::TbStructure(t),
_ => return Err(()),
};
Ok(out)
pub(crate) fn structurize(self) -> Self {
match self {
InfoStatement::Root(_) => InfoStatement::Root(true),
InfoStatement::Ns(_) => InfoStatement::Ns(true),
InfoStatement::Db(_) => InfoStatement::Db(true),
InfoStatement::Sc(s, _) => InfoStatement::Sc(s, true),
InfoStatement::Tb(t, _) => InfoStatement::Tb(t, true),
InfoStatement::User(u, b, _) => InfoStatement::User(u, b, true),
}
}
}

View file

@ -8,9 +8,9 @@ use revision::revisioned;
use serde::{Deserialize, Serialize};
use std::fmt;
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[revisioned(revision = 1)]
#[non_exhaustive]
pub struct InsertStatement {
pub into: Value,

View file

@ -13,9 +13,9 @@ use crate::kvs::lq_structs::{KillEntry, TrackedResult};
use crate::sql::Uuid;
use crate::sql::Value;
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[revisioned(revision = 1)]
#[non_exhaustive]
pub struct KillStatement {
// Uuid of Live Query

View file

@ -13,9 +13,9 @@ use revision::revisioned;
use serde::{Deserialize, Serialize};
use std::fmt;
#[revisioned(revision = 2)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[revisioned(revision = 2)]
#[non_exhaustive]
pub struct LiveStatement {
pub id: Uuid,

View file

@ -4,9 +4,9 @@ use revision::revisioned;
use serde::{Deserialize, Serialize};
use std::fmt;
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[revisioned(revision = 1)]
#[non_exhaustive]
pub struct OptionStatement {
pub name: Ident,

View file

@ -9,8 +9,8 @@ use revision::revisioned;
use serde::{Deserialize, Serialize};
use std::fmt;
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[revisioned(revision = 1)]
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Store, Hash)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[non_exhaustive]
pub struct OutputStatement {

Some files were not shown because too many files have changed in this diff Show more