Update 3rd party dependencies
This commit is contained in:
parent
cd26de7c3f
commit
351ef8264a
7 changed files with 186 additions and 199 deletions
127
Cargo.lock
generated
127
Cargo.lock
generated
|
@ -32,15 +32,6 @@ dependencies = [
|
|||
"alloc-no-stdlib",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ansi_term"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.53"
|
||||
|
@ -326,17 +317,17 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "2.34.0"
|
||||
version = "3.0.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c"
|
||||
checksum = "7a30c3bf9ff12dfe5dae53f0a96e0febcd18420d1c0e7fad77796d9d5c4b5375"
|
||||
dependencies = [
|
||||
"ansi_term",
|
||||
"atty",
|
||||
"bitflags",
|
||||
"indexmap",
|
||||
"os_str_bytes",
|
||||
"strsim",
|
||||
"termcolor",
|
||||
"textwrap",
|
||||
"unicode-width",
|
||||
"vec_map",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -402,16 +393,6 @@ dependencies = [
|
|||
"generic-array 0.14.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crypto-mac"
|
||||
version = "0.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714"
|
||||
dependencies = [
|
||||
"generic-array 0.14.5",
|
||||
"subtle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "derive-new"
|
||||
version = "0.5.9"
|
||||
|
@ -865,7 +846,7 @@ dependencies = [
|
|||
"http",
|
||||
"httpdate",
|
||||
"mime",
|
||||
"sha-1",
|
||||
"sha-1 0.9.8",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -913,16 +894,6 @@ version = "0.4.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
|
||||
|
||||
[[package]]
|
||||
name = "hmac"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b"
|
||||
dependencies = [
|
||||
"crypto-mac",
|
||||
"digest 0.9.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hmac"
|
||||
version = "0.12.0"
|
||||
|
@ -1166,13 +1137,11 @@ checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f"
|
|||
|
||||
[[package]]
|
||||
name = "md-5"
|
||||
version = "0.9.1"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7b5a279bb9607f9f53c22d496eade00d138d1bdcccd07d74650387cf94942a15"
|
||||
checksum = "e6a38fc55c8bbc10058782919516f88826e70320db6d206aebc49611d24216ae"
|
||||
dependencies = [
|
||||
"block-buffer 0.9.0",
|
||||
"digest 0.9.0",
|
||||
"opaque-debug",
|
||||
"digest 0.10.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1397,6 +1366,15 @@ dependencies = [
|
|||
"vcpkg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "os_str_bytes"
|
||||
version = "6.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot"
|
||||
version = "0.11.2"
|
||||
|
@ -1433,18 +1411,6 @@ dependencies = [
|
|||
"subtle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pbkdf2"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f05894bce6a1ba4be299d0c5f29563e08af2bc18bb7d48313113bed71e904739"
|
||||
dependencies = [
|
||||
"crypto-mac",
|
||||
"hmac 0.11.0",
|
||||
"password-hash",
|
||||
"sha2 0.9.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pbkdf2"
|
||||
version = "0.10.0"
|
||||
|
@ -1452,6 +1418,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "a4628cc3cf953b82edcd3c1388c5715401420ce5524fedbab426bd5aba017434"
|
||||
dependencies = [
|
||||
"digest 0.10.1",
|
||||
"hmac",
|
||||
"password-hash",
|
||||
"sha2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1907,11 +1876,11 @@ version = "0.8.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e73d6d7c6311ebdbd9184ad6c4447b2f36337e327bda107d3ba9e3c374f9d325"
|
||||
dependencies = [
|
||||
"hmac 0.12.0",
|
||||
"hmac",
|
||||
"password-hash",
|
||||
"pbkdf2 0.10.0",
|
||||
"pbkdf2",
|
||||
"salsa20",
|
||||
"sha2 0.10.1",
|
||||
"sha2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2004,16 +1973,14 @@ dependencies = [
|
|||
]
|
||||
|
||||
[[package]]
|
||||
name = "sha2"
|
||||
version = "0.9.9"
|
||||
name = "sha-1"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800"
|
||||
checksum = "028f48d513f9678cda28f6e4064755b3fbb2af6acd672f2c209b62323f7aea0f"
|
||||
dependencies = [
|
||||
"block-buffer 0.9.0",
|
||||
"cfg-if",
|
||||
"cpufeatures",
|
||||
"digest 0.9.0",
|
||||
"opaque-debug",
|
||||
"digest 0.10.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2082,9 +2049,9 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
|
|||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.8.0"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
|
||||
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
|
||||
|
||||
[[package]]
|
||||
name = "subtle"
|
||||
|
@ -2114,7 +2081,7 @@ dependencies = [
|
|||
"md-5",
|
||||
"nom 7.1.0",
|
||||
"once_cell",
|
||||
"pbkdf2 0.9.0",
|
||||
"pbkdf2",
|
||||
"rand 0.8.4",
|
||||
"regex",
|
||||
"reqwest",
|
||||
|
@ -2123,8 +2090,8 @@ dependencies = [
|
|||
"serde",
|
||||
"serde_cbor",
|
||||
"serde_json",
|
||||
"sha-1",
|
||||
"sha2 0.9.9",
|
||||
"sha-1 0.10.0",
|
||||
"sha2",
|
||||
"slug",
|
||||
"thiserror",
|
||||
"tikv-client",
|
||||
|
@ -2175,14 +2142,20 @@ dependencies = [
|
|||
]
|
||||
|
||||
[[package]]
|
||||
name = "textwrap"
|
||||
version = "0.11.0"
|
||||
name = "termcolor"
|
||||
version = "1.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
|
||||
checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4"
|
||||
dependencies = [
|
||||
"unicode-width",
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "textwrap"
|
||||
version = "0.14.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0066c8d12af8b5acd21e00547c3797fde4e8677254a7ee429176ccebbe93dd80"
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.30"
|
||||
|
@ -2445,7 +2418,7 @@ dependencies = [
|
|||
"httparse",
|
||||
"log",
|
||||
"rand 0.8.4",
|
||||
"sha-1",
|
||||
"sha-1 0.9.8",
|
||||
"thiserror",
|
||||
"url",
|
||||
"utf-8",
|
||||
|
@ -2496,12 +2469,6 @@ version = "1.8.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-width"
|
||||
version = "0.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-xid"
|
||||
version = "0.2.2"
|
||||
|
@ -2548,12 +2515,6 @@ version = "0.2.15"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
|
||||
|
||||
[[package]]
|
||||
name = "vec_map"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
|
||||
|
||||
[[package]]
|
||||
name = "version_check"
|
||||
version = "0.9.4"
|
||||
|
|
38
Cargo.toml
38
Cargo.toml
|
@ -6,35 +6,35 @@ version = "0.0.0"
|
|||
authors = ["Tobie Morgan Hitchcock <tobie@surrealdb.com>"]
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0.44"
|
||||
argon2 = "0.3.1"
|
||||
anyhow = "1.0.53"
|
||||
argon2 = "0.3.2"
|
||||
async-recursion = "1.0.0"
|
||||
byteorder = "1.4.3"
|
||||
bytes = "1.1.0"
|
||||
clap = "2.33.3"
|
||||
clap = "3.0.10"
|
||||
dmp = { git = "https://github.com/surrealdb/dmp", rev = "4d38162" }
|
||||
echodb = { git = "https://github.com/surrealdb/echodb", rev = "6b820e6" }
|
||||
futures = "0.3.17"
|
||||
futures = "0.3.19"
|
||||
fuzzy-matcher = "0.3.7"
|
||||
http = "0.2.5"
|
||||
http = "0.2.6"
|
||||
log = "0.4.14"
|
||||
md-5 = "0.9.1"
|
||||
nom = "7.0.0"
|
||||
once_cell = "1.8.0"
|
||||
pbkdf2 = "0.9.0"
|
||||
md-5 = "0.10.0"
|
||||
nom = "7.1.0"
|
||||
once_cell = "1.9.0"
|
||||
pbkdf2 = "0.10.0"
|
||||
rand = "0.8.4"
|
||||
regex = "1.5.4"
|
||||
scrypt = "0.8.0"
|
||||
sha-1 = "0.9.8"
|
||||
sha2 = "0.9.8"
|
||||
scrypt = "0.8.1"
|
||||
sha-1 = "0.10.0"
|
||||
sha2 = "0.10.1"
|
||||
slug = "0.1.4"
|
||||
thiserror = "1.0.29"
|
||||
thiserror = "1.0.30"
|
||||
url = "2.2.2"
|
||||
utf-8 = "0.7.6"
|
||||
xid = "1.0.0"
|
||||
|
||||
[dependencies.dec]
|
||||
version = "1.16.0"
|
||||
version = "1.20.0"
|
||||
package = "rust_decimal"
|
||||
features = ["maths", "serde-float"]
|
||||
|
||||
|
@ -51,7 +51,7 @@ version = "0.8.2"
|
|||
features = ["serde", "v4"]
|
||||
|
||||
[dependencies.warp]
|
||||
version = "0.3.1"
|
||||
version = "0.3.2"
|
||||
features = ["compression", "websocket"]
|
||||
|
||||
[dependencies.tikv]
|
||||
|
@ -59,11 +59,11 @@ version = "0.1.0"
|
|||
package = "tikv-client"
|
||||
|
||||
[dependencies.tokio]
|
||||
version = "1.12.0"
|
||||
version = "1.15.0"
|
||||
features = ["macros"]
|
||||
|
||||
[dependencies.reqwest]
|
||||
version = "0.11.5"
|
||||
version = "0.11.9"
|
||||
features = ["blocking"]
|
||||
|
||||
[dependencies.chrono]
|
||||
|
@ -71,11 +71,11 @@ version = "0.4.19"
|
|||
features = ["serde"]
|
||||
|
||||
[dependencies.serde]
|
||||
version = "1.0.130"
|
||||
version = "1.0.135"
|
||||
features = ["derive"]
|
||||
|
||||
[dependencies.serde_cbor]
|
||||
version = "0.11.2"
|
||||
|
||||
[dependencies.serde_json]
|
||||
version = "1.0.68"
|
||||
version = "1.0.78"
|
||||
|
|
178
src/cli/mod.rs
178
src/cli/mod.rs
|
@ -5,9 +5,9 @@ mod log;
|
|||
mod start;
|
||||
mod version;
|
||||
|
||||
use clap::{App, AppSettings, Arg, SubCommand};
|
||||
use clap::{App, AppSettings, Arg};
|
||||
|
||||
fn auth_valid(v: String) -> Result<(), String> {
|
||||
fn auth_valid(v: &str) -> Result<(), String> {
|
||||
if v.contains(":") {
|
||||
return Ok(());
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ fn auth_valid(v: String) -> Result<(), String> {
|
|||
))
|
||||
}
|
||||
|
||||
fn file_valid(v: String) -> Result<(), String> {
|
||||
fn file_valid(v: &str) -> Result<(), String> {
|
||||
if v.len() > 0 {
|
||||
return Ok(());
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ fn file_valid(v: String) -> Result<(), String> {
|
|||
))
|
||||
}
|
||||
|
||||
fn path_valid(v: String) -> Result<(), String> {
|
||||
fn path_valid(v: &str) -> Result<(), String> {
|
||||
if v == "memory" {
|
||||
return Ok(());
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ fn path_valid(v: String) -> Result<(), String> {
|
|||
))
|
||||
}
|
||||
|
||||
fn conn_valid(v: String) -> Result<(), String> {
|
||||
fn conn_valid(v: &str) -> Result<(), String> {
|
||||
if v.starts_with("https://") {
|
||||
return Ok(());
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ fn conn_valid(v: String) -> Result<(), String> {
|
|||
))
|
||||
}
|
||||
|
||||
fn from_valid(v: String) -> Result<(), String> {
|
||||
fn from_valid(v: &str) -> Result<(), String> {
|
||||
if v.starts_with("https://") {
|
||||
return Ok(());
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ fn from_valid(v: String) -> Result<(), String> {
|
|||
))
|
||||
}
|
||||
|
||||
fn into_valid(v: String) -> Result<(), String> {
|
||||
fn into_valid(v: &str) -> Result<(), String> {
|
||||
if v.starts_with("https://") {
|
||||
return Ok(());
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ fn into_valid(v: String) -> Result<(), String> {
|
|||
))
|
||||
}
|
||||
|
||||
fn key_valid(v: String) -> Result<(), String> {
|
||||
fn key_valid(v: &str) -> Result<(), String> {
|
||||
match v.len() {
|
||||
16 => Ok(()),
|
||||
24 => Ok(()),
|
||||
|
@ -114,263 +114,263 @@ fn key_valid(v: String) -> Result<(), String> {
|
|||
|
||||
pub fn init() {
|
||||
let setup = App::new("SurrealDB command-line interface and server")
|
||||
.setting(AppSettings::DisableVersion)
|
||||
.setting(AppSettings::DisableVersionFlag)
|
||||
.setting(AppSettings::ArgRequiredElseHelp)
|
||||
.setting(AppSettings::VersionlessSubcommands)
|
||||
.arg(
|
||||
Arg::with_name("verbose")
|
||||
.short("v")
|
||||
Arg::new("verbose")
|
||||
.short('v')
|
||||
.long("verbose")
|
||||
.multiple(true)
|
||||
.takes_value(false)
|
||||
.multiple_occurrences(true)
|
||||
.help("Specify the log output verbosity"),
|
||||
);
|
||||
|
||||
let setup = setup.subcommand(
|
||||
SubCommand::with_name("start")
|
||||
App::new("start")
|
||||
.display_order(1)
|
||||
.about("Start the database server")
|
||||
.arg(
|
||||
Arg::with_name("path")
|
||||
Arg::new("path")
|
||||
.index(1)
|
||||
.required(true)
|
||||
.required(false)
|
||||
.validator(path_valid)
|
||||
.default_value("memory")
|
||||
.help("Database path used for storing data"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("auth")
|
||||
.short("a")
|
||||
Arg::new("auth")
|
||||
.short('a')
|
||||
.long("auth")
|
||||
.empty_values(false)
|
||||
.forbid_empty_values(true)
|
||||
.validator(auth_valid)
|
||||
.default_value("root:root")
|
||||
.help("Master database authentication details"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("auth-user")
|
||||
.short("u")
|
||||
Arg::new("auth-user")
|
||||
.short('u')
|
||||
.long("auth-user")
|
||||
.empty_values(false)
|
||||
.forbid_empty_values(true)
|
||||
.default_value("root")
|
||||
.help("The master username for the database"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("auth-pass")
|
||||
.short("p")
|
||||
Arg::new("auth-pass")
|
||||
.short('p')
|
||||
.long("auth-pass")
|
||||
.empty_values(false)
|
||||
.forbid_empty_values(true)
|
||||
.default_value("root")
|
||||
.help("The master password for the database"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("auth-addr")
|
||||
Arg::new("auth-addr")
|
||||
.long("auth-addr")
|
||||
.multiple(true)
|
||||
.empty_values(false)
|
||||
.number_of_values(1)
|
||||
.forbid_empty_values(true)
|
||||
.multiple_occurrences(true)
|
||||
.default_value("127.0.0.1/32")
|
||||
.help("The allowed networks for master authentication"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("bind")
|
||||
.short("b")
|
||||
Arg::new("bind")
|
||||
.short('b')
|
||||
.long("bind")
|
||||
.empty_values(false)
|
||||
.forbid_empty_values(true)
|
||||
.default_value("0.0.0.0:3000")
|
||||
.help("The hostname or ip address to listen for connections on"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("key")
|
||||
.short("k")
|
||||
Arg::new("key")
|
||||
.short('k')
|
||||
.long("key")
|
||||
.takes_value(true)
|
||||
.empty_values(false)
|
||||
.forbid_empty_values(true)
|
||||
.validator(key_valid)
|
||||
.help("Encryption key to use for on-disk encryption"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("kvs-ca")
|
||||
Arg::new("kvs-ca")
|
||||
.long("kvs-ca")
|
||||
.takes_value(true)
|
||||
.empty_values(false)
|
||||
.forbid_empty_values(true)
|
||||
.help("Path to the CA file used when connecting to the remote KV store"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("kvs-crt")
|
||||
Arg::new("kvs-crt")
|
||||
.long("kvs-crt")
|
||||
.takes_value(true)
|
||||
.empty_values(false)
|
||||
.forbid_empty_values(true)
|
||||
.help(
|
||||
"Path to the certificate file used when connecting to the remote KV store",
|
||||
),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("kvs-key")
|
||||
Arg::new("kvs-key")
|
||||
.long("kvs-key")
|
||||
.takes_value(true)
|
||||
.empty_values(false)
|
||||
.forbid_empty_values(true)
|
||||
.help(
|
||||
"Path to the private key file used when connecting to the remote KV store",
|
||||
),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("web-crt")
|
||||
Arg::new("web-crt")
|
||||
.long("web-crt")
|
||||
.takes_value(true)
|
||||
.empty_values(false)
|
||||
.forbid_empty_values(true)
|
||||
.help("Path to the certificate file for encrypted client connections"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("web-key")
|
||||
Arg::new("web-key")
|
||||
.long("web-key")
|
||||
.takes_value(true)
|
||||
.empty_values(false)
|
||||
.forbid_empty_values(true)
|
||||
.help("Path to the private key file for encrypted client connections"),
|
||||
),
|
||||
);
|
||||
|
||||
let setup = setup.subcommand(
|
||||
SubCommand::with_name("backup")
|
||||
App::new("backup")
|
||||
.display_order(2)
|
||||
.about("Backup data to or from an existing database")
|
||||
.arg(
|
||||
Arg::with_name("from")
|
||||
Arg::new("from")
|
||||
.index(1)
|
||||
.required(true)
|
||||
.validator(from_valid)
|
||||
.help("Path to the remote database or file from which to export"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("into")
|
||||
Arg::new("into")
|
||||
.index(2)
|
||||
.required(true)
|
||||
.validator(into_valid)
|
||||
.help("Path to the remote database or file into which to import"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("user")
|
||||
.short("u")
|
||||
Arg::new("user")
|
||||
.short('u')
|
||||
.long("user")
|
||||
.empty_values(false)
|
||||
.forbid_empty_values(true)
|
||||
.default_value("root")
|
||||
.help("Database authentication username to use when connecting"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("pass")
|
||||
.short("p")
|
||||
Arg::new("pass")
|
||||
.short('p')
|
||||
.long("pass")
|
||||
.empty_values(false)
|
||||
.forbid_empty_values(true)
|
||||
.default_value("root")
|
||||
.help("Database authentication password to use when connecting"),
|
||||
),
|
||||
);
|
||||
|
||||
let setup = setup.subcommand(
|
||||
SubCommand::with_name("import")
|
||||
App::new("import")
|
||||
.display_order(3)
|
||||
.about("Import a SQL script into an existing database")
|
||||
.arg(
|
||||
Arg::with_name("file")
|
||||
Arg::new("file")
|
||||
.index(1)
|
||||
.required(true)
|
||||
.validator(file_valid)
|
||||
.help("Path to the sql file to import"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("ns")
|
||||
Arg::new("ns")
|
||||
.long("ns")
|
||||
.required(true)
|
||||
.empty_values(false)
|
||||
.forbid_empty_values(true)
|
||||
.help("The namespace to import the data into"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("db")
|
||||
Arg::new("db")
|
||||
.long("db")
|
||||
.required(true)
|
||||
.empty_values(false)
|
||||
.forbid_empty_values(true)
|
||||
.help("The database to import the data into"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("conn")
|
||||
.short("c")
|
||||
Arg::new("conn")
|
||||
.short('c')
|
||||
.long("conn")
|
||||
.empty_values(false)
|
||||
.forbid_empty_values(true)
|
||||
.validator(conn_valid)
|
||||
.default_value("https://surreal.io")
|
||||
.help("Remote database server url to connect to"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("user")
|
||||
.short("u")
|
||||
Arg::new("user")
|
||||
.short('u')
|
||||
.long("user")
|
||||
.empty_values(false)
|
||||
.forbid_empty_values(true)
|
||||
.default_value("root")
|
||||
.help("Database authentication username to use when connecting"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("pass")
|
||||
.short("p")
|
||||
Arg::new("pass")
|
||||
.short('p')
|
||||
.long("pass")
|
||||
.empty_values(false)
|
||||
.forbid_empty_values(true)
|
||||
.default_value("root")
|
||||
.help("Database authentication password to use when connecting"),
|
||||
),
|
||||
);
|
||||
|
||||
let setup = setup.subcommand(
|
||||
SubCommand::with_name("export")
|
||||
App::new("export")
|
||||
.display_order(4)
|
||||
.about("Export an existing database into a SQL script")
|
||||
.arg(
|
||||
Arg::with_name("file")
|
||||
Arg::new("file")
|
||||
.index(1)
|
||||
.required(true)
|
||||
.validator(file_valid)
|
||||
.help("Path to the sql file to export"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("ns")
|
||||
Arg::new("ns")
|
||||
.long("ns")
|
||||
.required(true)
|
||||
.empty_values(false)
|
||||
.forbid_empty_values(true)
|
||||
.help("The namespace to export the data from"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("db")
|
||||
Arg::new("db")
|
||||
.long("db")
|
||||
.required(true)
|
||||
.empty_values(false)
|
||||
.forbid_empty_values(true)
|
||||
.help("The database to export the data from"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("conn")
|
||||
.short("c")
|
||||
Arg::new("conn")
|
||||
.short('c')
|
||||
.long("conn")
|
||||
.empty_values(false)
|
||||
.forbid_empty_values(true)
|
||||
.validator(conn_valid)
|
||||
.default_value("https://surreal.io")
|
||||
.help("Remote database server url to connect to"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("user")
|
||||
.short("u")
|
||||
Arg::new("user")
|
||||
.short('u')
|
||||
.long("user")
|
||||
.empty_values(false)
|
||||
.forbid_empty_values(true)
|
||||
.default_value("root")
|
||||
.help("Database authentication username to use when connecting"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("pass")
|
||||
.short("p")
|
||||
Arg::new("pass")
|
||||
.short('p')
|
||||
.long("pass")
|
||||
.empty_values(false)
|
||||
.forbid_empty_values(true)
|
||||
.default_value("root")
|
||||
.help("Database authentication password to use when connecting"),
|
||||
),
|
||||
);
|
||||
|
||||
let setup = setup.subcommand(
|
||||
SubCommand::with_name("version")
|
||||
App::new("version")
|
||||
.display_order(5)
|
||||
.about("Output the command-line tool version information"),
|
||||
);
|
||||
|
@ -382,11 +382,11 @@ pub fn init() {
|
|||
log::init(verbose);
|
||||
|
||||
let output = match matches.subcommand() {
|
||||
("start", Some(m)) => start::init(m),
|
||||
("backup", Some(m)) => backup::init(m),
|
||||
("import", Some(m)) => import::init(m),
|
||||
("export", Some(m)) => export::init(m),
|
||||
("version", Some(m)) => version::init(m),
|
||||
Some(("start", m)) => start::init(m),
|
||||
Some(("backup", m)) => backup::init(m),
|
||||
Some(("import", m)) => import::init(m),
|
||||
Some(("export", m)) => export::init(m),
|
||||
Some(("version", m)) => version::init(m),
|
||||
_ => Ok(()),
|
||||
};
|
||||
|
||||
|
|
|
@ -118,6 +118,7 @@ fn custom(i: &str) -> IResult<&str, (Tables, Option<Value>, Option<Idiom>)> {
|
|||
let (i, w) = what(i)?;
|
||||
let (i, c) = opt(cond)(i)?;
|
||||
let (i, a) = opt(alias)(i)?;
|
||||
let (i, _) = mightbespace(i)?;
|
||||
let (i, _) = tag(")")(i)?;
|
||||
Ok((i, (w, c, a)))
|
||||
}
|
||||
|
@ -195,6 +196,15 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn graph_conditions() {
|
||||
let sql = "->(likes, follows WHERE influencer = true)";
|
||||
let res = graph(sql);
|
||||
assert!(res.is_ok());
|
||||
let out = res.unwrap().1;
|
||||
assert_eq!("->(likes, follows WHERE influencer = true)", format!("{}", out));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn graph_conditions_aliases() {
|
||||
let sql = "->(likes, follows WHERE influencer = true AS connections)";
|
||||
let res = graph(sql);
|
||||
assert!(res.is_ok());
|
||||
|
|
|
@ -3,7 +3,7 @@ use dec::prelude::FromPrimitive;
|
|||
use dec::prelude::ToPrimitive;
|
||||
use dec::Decimal;
|
||||
use dec::MathematicalOps;
|
||||
use nom::number::complete::double;
|
||||
use nom::number::complete::recognize_float;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::cmp::Ordering;
|
||||
use std::fmt;
|
||||
|
@ -49,6 +49,12 @@ impl From<i64> for Number {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<i128> for Number {
|
||||
fn from(i: i128) -> Self {
|
||||
Number::Decimal(Decimal::from(i))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<isize> for Number {
|
||||
fn from(i: isize) -> Self {
|
||||
Number::Decimal(Decimal::from(i))
|
||||
|
@ -79,6 +85,12 @@ impl From<u64> for Number {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<u128> for Number {
|
||||
fn from(i: u128) -> Self {
|
||||
Number::Decimal(Decimal::from(i))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<usize> for Number {
|
||||
fn from(i: usize) -> Self {
|
||||
Number::Decimal(Decimal::from(i))
|
||||
|
@ -87,25 +99,31 @@ impl From<usize> for Number {
|
|||
|
||||
impl From<f32> for Number {
|
||||
fn from(f: f32) -> Self {
|
||||
Number::Decimal(Decimal::from_f64(f as f64).unwrap_or(Decimal::new(0, 0)))
|
||||
Number::Decimal(Decimal::from_f32(f).unwrap_or(Decimal::new(0, 0)))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<f64> for Number {
|
||||
fn from(f: f64) -> Self {
|
||||
Number::Decimal(Decimal::from_f64(f as f64).unwrap_or(Decimal::new(0, 0)))
|
||||
Number::Decimal(Decimal::from_f64(f).unwrap_or(Decimal::new(0, 0)))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&'a str> for Number {
|
||||
fn from(s: &str) -> Self {
|
||||
Number::Decimal(Decimal::from_str(s).unwrap_or(Decimal::new(0, 0)))
|
||||
match s.contains(&['e', 'E'][..]) {
|
||||
true => Number::Decimal(Decimal::from_scientific(s).unwrap_or(Decimal::new(0, 0))),
|
||||
false => Number::Decimal(Decimal::from_str(s).unwrap_or(Decimal::new(0, 0))),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<String> for Number {
|
||||
fn from(s: String) -> Self {
|
||||
Number::Decimal(Decimal::from_str(&s).unwrap_or(Decimal::new(0, 0)))
|
||||
match s.contains(&['e', 'E'][..]) {
|
||||
true => Number::Decimal(Decimal::from_scientific(&s).unwrap_or(Decimal::new(0, 0))),
|
||||
false => Number::Decimal(Decimal::from_str(&s).unwrap_or(Decimal::new(0, 0))),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -485,7 +503,7 @@ impl<'a> Product<&'a Self> for Number {
|
|||
}
|
||||
|
||||
pub fn number(i: &str) -> IResult<&str, Number> {
|
||||
let (i, v) = double(i)?;
|
||||
let (i, v) = recognize_float(i)?;
|
||||
Ok((i, Number::from(v)))
|
||||
}
|
||||
|
||||
|
|
|
@ -112,7 +112,6 @@ mod tests {
|
|||
tags[$].value,
|
||||
3s as duration,
|
||||
1.345 AS number,
|
||||
-999999999999999.9999999 AS double,
|
||||
test AS `some thing`,
|
||||
'2012-04-23T18:25:43.511Z' AS utctime,
|
||||
'2012-04-23T18:25:43.511-08:00' AS pacifictime,
|
||||
|
|
|
@ -125,7 +125,6 @@ mod tests {
|
|||
fn update_statement() {
|
||||
let sql = "UPDATE test";
|
||||
let res = update(sql);
|
||||
println!("{:?}", res);
|
||||
assert!(res.is_ok());
|
||||
let out = res.unwrap().1;
|
||||
assert_eq!("UPDATE test", format!("{}", out))
|
||||
|
|
Loading…
Reference in a new issue