Update 3rd party dependencies

This commit is contained in:
Tobie Morgan Hitchcock 2022-01-23 12:30:59 +00:00
parent cd26de7c3f
commit 351ef8264a
7 changed files with 186 additions and 199 deletions

127
Cargo.lock generated
View file

@ -32,15 +32,6 @@ dependencies = [
"alloc-no-stdlib", "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]] [[package]]
name = "anyhow" name = "anyhow"
version = "1.0.53" version = "1.0.53"
@ -326,17 +317,17 @@ dependencies = [
[[package]] [[package]]
name = "clap" name = "clap"
version = "2.34.0" version = "3.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" checksum = "7a30c3bf9ff12dfe5dae53f0a96e0febcd18420d1c0e7fad77796d9d5c4b5375"
dependencies = [ dependencies = [
"ansi_term",
"atty", "atty",
"bitflags", "bitflags",
"indexmap",
"os_str_bytes",
"strsim", "strsim",
"termcolor",
"textwrap", "textwrap",
"unicode-width",
"vec_map",
] ]
[[package]] [[package]]
@ -402,16 +393,6 @@ dependencies = [
"generic-array 0.14.5", "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]] [[package]]
name = "derive-new" name = "derive-new"
version = "0.5.9" version = "0.5.9"
@ -865,7 +846,7 @@ dependencies = [
"http", "http",
"httpdate", "httpdate",
"mime", "mime",
"sha-1", "sha-1 0.9.8",
] ]
[[package]] [[package]]
@ -913,16 +894,6 @@ version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" 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]] [[package]]
name = "hmac" name = "hmac"
version = "0.12.0" version = "0.12.0"
@ -1166,13 +1137,11 @@ checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f"
[[package]] [[package]]
name = "md-5" name = "md-5"
version = "0.9.1" version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b5a279bb9607f9f53c22d496eade00d138d1bdcccd07d74650387cf94942a15" checksum = "e6a38fc55c8bbc10058782919516f88826e70320db6d206aebc49611d24216ae"
dependencies = [ dependencies = [
"block-buffer 0.9.0", "digest 0.10.1",
"digest 0.9.0",
"opaque-debug",
] ]
[[package]] [[package]]
@ -1397,6 +1366,15 @@ dependencies = [
"vcpkg", "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]] [[package]]
name = "parking_lot" name = "parking_lot"
version = "0.11.2" version = "0.11.2"
@ -1433,18 +1411,6 @@ dependencies = [
"subtle", "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]] [[package]]
name = "pbkdf2" name = "pbkdf2"
version = "0.10.0" version = "0.10.0"
@ -1452,6 +1418,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4628cc3cf953b82edcd3c1388c5715401420ce5524fedbab426bd5aba017434" checksum = "a4628cc3cf953b82edcd3c1388c5715401420ce5524fedbab426bd5aba017434"
dependencies = [ dependencies = [
"digest 0.10.1", "digest 0.10.1",
"hmac",
"password-hash",
"sha2",
] ]
[[package]] [[package]]
@ -1907,11 +1876,11 @@ version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e73d6d7c6311ebdbd9184ad6c4447b2f36337e327bda107d3ba9e3c374f9d325" checksum = "e73d6d7c6311ebdbd9184ad6c4447b2f36337e327bda107d3ba9e3c374f9d325"
dependencies = [ dependencies = [
"hmac 0.12.0", "hmac",
"password-hash", "password-hash",
"pbkdf2 0.10.0", "pbkdf2",
"salsa20", "salsa20",
"sha2 0.10.1", "sha2",
] ]
[[package]] [[package]]
@ -2004,16 +1973,14 @@ dependencies = [
] ]
[[package]] [[package]]
name = "sha2" name = "sha-1"
version = "0.9.9" version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" checksum = "028f48d513f9678cda28f6e4064755b3fbb2af6acd672f2c209b62323f7aea0f"
dependencies = [ dependencies = [
"block-buffer 0.9.0",
"cfg-if", "cfg-if",
"cpufeatures", "cpufeatures",
"digest 0.9.0", "digest 0.10.1",
"opaque-debug",
] ]
[[package]] [[package]]
@ -2082,9 +2049,9 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
[[package]] [[package]]
name = "strsim" name = "strsim"
version = "0.8.0" version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]] [[package]]
name = "subtle" name = "subtle"
@ -2114,7 +2081,7 @@ dependencies = [
"md-5", "md-5",
"nom 7.1.0", "nom 7.1.0",
"once_cell", "once_cell",
"pbkdf2 0.9.0", "pbkdf2",
"rand 0.8.4", "rand 0.8.4",
"regex", "regex",
"reqwest", "reqwest",
@ -2123,8 +2090,8 @@ dependencies = [
"serde", "serde",
"serde_cbor", "serde_cbor",
"serde_json", "serde_json",
"sha-1", "sha-1 0.10.0",
"sha2 0.9.9", "sha2",
"slug", "slug",
"thiserror", "thiserror",
"tikv-client", "tikv-client",
@ -2175,14 +2142,20 @@ dependencies = [
] ]
[[package]] [[package]]
name = "textwrap" name = "termcolor"
version = "0.11.0" version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4"
dependencies = [ 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]] [[package]]
name = "thiserror" name = "thiserror"
version = "1.0.30" version = "1.0.30"
@ -2445,7 +2418,7 @@ dependencies = [
"httparse", "httparse",
"log", "log",
"rand 0.8.4", "rand 0.8.4",
"sha-1", "sha-1 0.9.8",
"thiserror", "thiserror",
"url", "url",
"utf-8", "utf-8",
@ -2496,12 +2469,6 @@ version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b" checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b"
[[package]]
name = "unicode-width"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973"
[[package]] [[package]]
name = "unicode-xid" name = "unicode-xid"
version = "0.2.2" version = "0.2.2"
@ -2548,12 +2515,6 @@ version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
[[package]]
name = "vec_map"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
[[package]] [[package]]
name = "version_check" name = "version_check"
version = "0.9.4" version = "0.9.4"

View file

@ -6,35 +6,35 @@ version = "0.0.0"
authors = ["Tobie Morgan Hitchcock <tobie@surrealdb.com>"] authors = ["Tobie Morgan Hitchcock <tobie@surrealdb.com>"]
[dependencies] [dependencies]
anyhow = "1.0.44" anyhow = "1.0.53"
argon2 = "0.3.1" argon2 = "0.3.2"
async-recursion = "1.0.0" async-recursion = "1.0.0"
byteorder = "1.4.3" byteorder = "1.4.3"
bytes = "1.1.0" bytes = "1.1.0"
clap = "2.33.3" clap = "3.0.10"
dmp = { git = "https://github.com/surrealdb/dmp", rev = "4d38162" } dmp = { git = "https://github.com/surrealdb/dmp", rev = "4d38162" }
echodb = { git = "https://github.com/surrealdb/echodb", rev = "6b820e6" } echodb = { git = "https://github.com/surrealdb/echodb", rev = "6b820e6" }
futures = "0.3.17" futures = "0.3.19"
fuzzy-matcher = "0.3.7" fuzzy-matcher = "0.3.7"
http = "0.2.5" http = "0.2.6"
log = "0.4.14" log = "0.4.14"
md-5 = "0.9.1" md-5 = "0.10.0"
nom = "7.0.0" nom = "7.1.0"
once_cell = "1.8.0" once_cell = "1.9.0"
pbkdf2 = "0.9.0" pbkdf2 = "0.10.0"
rand = "0.8.4" rand = "0.8.4"
regex = "1.5.4" regex = "1.5.4"
scrypt = "0.8.0" scrypt = "0.8.1"
sha-1 = "0.9.8" sha-1 = "0.10.0"
sha2 = "0.9.8" sha2 = "0.10.1"
slug = "0.1.4" slug = "0.1.4"
thiserror = "1.0.29" thiserror = "1.0.30"
url = "2.2.2" url = "2.2.2"
utf-8 = "0.7.6" utf-8 = "0.7.6"
xid = "1.0.0" xid = "1.0.0"
[dependencies.dec] [dependencies.dec]
version = "1.16.0" version = "1.20.0"
package = "rust_decimal" package = "rust_decimal"
features = ["maths", "serde-float"] features = ["maths", "serde-float"]
@ -51,7 +51,7 @@ version = "0.8.2"
features = ["serde", "v4"] features = ["serde", "v4"]
[dependencies.warp] [dependencies.warp]
version = "0.3.1" version = "0.3.2"
features = ["compression", "websocket"] features = ["compression", "websocket"]
[dependencies.tikv] [dependencies.tikv]
@ -59,11 +59,11 @@ version = "0.1.0"
package = "tikv-client" package = "tikv-client"
[dependencies.tokio] [dependencies.tokio]
version = "1.12.0" version = "1.15.0"
features = ["macros"] features = ["macros"]
[dependencies.reqwest] [dependencies.reqwest]
version = "0.11.5" version = "0.11.9"
features = ["blocking"] features = ["blocking"]
[dependencies.chrono] [dependencies.chrono]
@ -71,11 +71,11 @@ version = "0.4.19"
features = ["serde"] features = ["serde"]
[dependencies.serde] [dependencies.serde]
version = "1.0.130" version = "1.0.135"
features = ["derive"] features = ["derive"]
[dependencies.serde_cbor] [dependencies.serde_cbor]
version = "0.11.2" version = "0.11.2"
[dependencies.serde_json] [dependencies.serde_json]
version = "1.0.68" version = "1.0.78"

View file

@ -5,9 +5,9 @@ mod log;
mod start; mod start;
mod version; 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(":") { if v.contains(":") {
return Ok(()); 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 { if v.len() > 0 {
return Ok(()); 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" { if v == "memory" {
return Ok(()); 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://") { if v.starts_with("https://") {
return Ok(()); 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://") { if v.starts_with("https://") {
return Ok(()); 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://") { if v.starts_with("https://") {
return Ok(()); 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() { match v.len() {
16 => Ok(()), 16 => Ok(()),
24 => Ok(()), 24 => Ok(()),
@ -114,263 +114,263 @@ fn key_valid(v: String) -> Result<(), String> {
pub fn init() { pub fn init() {
let setup = App::new("SurrealDB command-line interface and server") let setup = App::new("SurrealDB command-line interface and server")
.setting(AppSettings::DisableVersion) .setting(AppSettings::DisableVersionFlag)
.setting(AppSettings::ArgRequiredElseHelp) .setting(AppSettings::ArgRequiredElseHelp)
.setting(AppSettings::VersionlessSubcommands)
.arg( .arg(
Arg::with_name("verbose") Arg::new("verbose")
.short("v") .short('v')
.long("verbose") .long("verbose")
.multiple(true) .takes_value(false)
.multiple_occurrences(true)
.help("Specify the log output verbosity"), .help("Specify the log output verbosity"),
); );
let setup = setup.subcommand( let setup = setup.subcommand(
SubCommand::with_name("start") App::new("start")
.display_order(1) .display_order(1)
.about("Start the database server") .about("Start the database server")
.arg( .arg(
Arg::with_name("path") Arg::new("path")
.index(1) .index(1)
.required(true) .required(false)
.validator(path_valid) .validator(path_valid)
.default_value("memory") .default_value("memory")
.help("Database path used for storing data"), .help("Database path used for storing data"),
) )
.arg( .arg(
Arg::with_name("auth") Arg::new("auth")
.short("a") .short('a')
.long("auth") .long("auth")
.empty_values(false) .forbid_empty_values(true)
.validator(auth_valid) .validator(auth_valid)
.default_value("root:root") .default_value("root:root")
.help("Master database authentication details"), .help("Master database authentication details"),
) )
.arg( .arg(
Arg::with_name("auth-user") Arg::new("auth-user")
.short("u") .short('u')
.long("auth-user") .long("auth-user")
.empty_values(false) .forbid_empty_values(true)
.default_value("root") .default_value("root")
.help("The master username for the database"), .help("The master username for the database"),
) )
.arg( .arg(
Arg::with_name("auth-pass") Arg::new("auth-pass")
.short("p") .short('p')
.long("auth-pass") .long("auth-pass")
.empty_values(false) .forbid_empty_values(true)
.default_value("root") .default_value("root")
.help("The master password for the database"), .help("The master password for the database"),
) )
.arg( .arg(
Arg::with_name("auth-addr") Arg::new("auth-addr")
.long("auth-addr") .long("auth-addr")
.multiple(true)
.empty_values(false)
.number_of_values(1) .number_of_values(1)
.forbid_empty_values(true)
.multiple_occurrences(true)
.default_value("127.0.0.1/32") .default_value("127.0.0.1/32")
.help("The allowed networks for master authentication"), .help("The allowed networks for master authentication"),
) )
.arg( .arg(
Arg::with_name("bind") Arg::new("bind")
.short("b") .short('b')
.long("bind") .long("bind")
.empty_values(false) .forbid_empty_values(true)
.default_value("0.0.0.0:3000") .default_value("0.0.0.0:3000")
.help("The hostname or ip address to listen for connections on"), .help("The hostname or ip address to listen for connections on"),
) )
.arg( .arg(
Arg::with_name("key") Arg::new("key")
.short("k") .short('k')
.long("key") .long("key")
.takes_value(true) .takes_value(true)
.empty_values(false) .forbid_empty_values(true)
.validator(key_valid) .validator(key_valid)
.help("Encryption key to use for on-disk encryption"), .help("Encryption key to use for on-disk encryption"),
) )
.arg( .arg(
Arg::with_name("kvs-ca") Arg::new("kvs-ca")
.long("kvs-ca") .long("kvs-ca")
.takes_value(true) .takes_value(true)
.empty_values(false) .forbid_empty_values(true)
.help("Path to the CA file used when connecting to the remote KV store"), .help("Path to the CA file used when connecting to the remote KV store"),
) )
.arg( .arg(
Arg::with_name("kvs-crt") Arg::new("kvs-crt")
.long("kvs-crt") .long("kvs-crt")
.takes_value(true) .takes_value(true)
.empty_values(false) .forbid_empty_values(true)
.help( .help(
"Path to the certificate file used when connecting to the remote KV store", "Path to the certificate file used when connecting to the remote KV store",
), ),
) )
.arg( .arg(
Arg::with_name("kvs-key") Arg::new("kvs-key")
.long("kvs-key") .long("kvs-key")
.takes_value(true) .takes_value(true)
.empty_values(false) .forbid_empty_values(true)
.help( .help(
"Path to the private key file used when connecting to the remote KV store", "Path to the private key file used when connecting to the remote KV store",
), ),
) )
.arg( .arg(
Arg::with_name("web-crt") Arg::new("web-crt")
.long("web-crt") .long("web-crt")
.takes_value(true) .takes_value(true)
.empty_values(false) .forbid_empty_values(true)
.help("Path to the certificate file for encrypted client connections"), .help("Path to the certificate file for encrypted client connections"),
) )
.arg( .arg(
Arg::with_name("web-key") Arg::new("web-key")
.long("web-key") .long("web-key")
.takes_value(true) .takes_value(true)
.empty_values(false) .forbid_empty_values(true)
.help("Path to the private key file for encrypted client connections"), .help("Path to the private key file for encrypted client connections"),
), ),
); );
let setup = setup.subcommand( let setup = setup.subcommand(
SubCommand::with_name("backup") App::new("backup")
.display_order(2) .display_order(2)
.about("Backup data to or from an existing database") .about("Backup data to or from an existing database")
.arg( .arg(
Arg::with_name("from") Arg::new("from")
.index(1) .index(1)
.required(true) .required(true)
.validator(from_valid) .validator(from_valid)
.help("Path to the remote database or file from which to export"), .help("Path to the remote database or file from which to export"),
) )
.arg( .arg(
Arg::with_name("into") Arg::new("into")
.index(2) .index(2)
.required(true) .required(true)
.validator(into_valid) .validator(into_valid)
.help("Path to the remote database or file into which to import"), .help("Path to the remote database or file into which to import"),
) )
.arg( .arg(
Arg::with_name("user") Arg::new("user")
.short("u") .short('u')
.long("user") .long("user")
.empty_values(false) .forbid_empty_values(true)
.default_value("root") .default_value("root")
.help("Database authentication username to use when connecting"), .help("Database authentication username to use when connecting"),
) )
.arg( .arg(
Arg::with_name("pass") Arg::new("pass")
.short("p") .short('p')
.long("pass") .long("pass")
.empty_values(false) .forbid_empty_values(true)
.default_value("root") .default_value("root")
.help("Database authentication password to use when connecting"), .help("Database authentication password to use when connecting"),
), ),
); );
let setup = setup.subcommand( let setup = setup.subcommand(
SubCommand::with_name("import") App::new("import")
.display_order(3) .display_order(3)
.about("Import a SQL script into an existing database") .about("Import a SQL script into an existing database")
.arg( .arg(
Arg::with_name("file") Arg::new("file")
.index(1) .index(1)
.required(true) .required(true)
.validator(file_valid) .validator(file_valid)
.help("Path to the sql file to import"), .help("Path to the sql file to import"),
) )
.arg( .arg(
Arg::with_name("ns") Arg::new("ns")
.long("ns") .long("ns")
.required(true) .required(true)
.empty_values(false) .forbid_empty_values(true)
.help("The namespace to import the data into"), .help("The namespace to import the data into"),
) )
.arg( .arg(
Arg::with_name("db") Arg::new("db")
.long("db") .long("db")
.required(true) .required(true)
.empty_values(false) .forbid_empty_values(true)
.help("The database to import the data into"), .help("The database to import the data into"),
) )
.arg( .arg(
Arg::with_name("conn") Arg::new("conn")
.short("c") .short('c')
.long("conn") .long("conn")
.empty_values(false) .forbid_empty_values(true)
.validator(conn_valid) .validator(conn_valid)
.default_value("https://surreal.io") .default_value("https://surreal.io")
.help("Remote database server url to connect to"), .help("Remote database server url to connect to"),
) )
.arg( .arg(
Arg::with_name("user") Arg::new("user")
.short("u") .short('u')
.long("user") .long("user")
.empty_values(false) .forbid_empty_values(true)
.default_value("root") .default_value("root")
.help("Database authentication username to use when connecting"), .help("Database authentication username to use when connecting"),
) )
.arg( .arg(
Arg::with_name("pass") Arg::new("pass")
.short("p") .short('p')
.long("pass") .long("pass")
.empty_values(false) .forbid_empty_values(true)
.default_value("root") .default_value("root")
.help("Database authentication password to use when connecting"), .help("Database authentication password to use when connecting"),
), ),
); );
let setup = setup.subcommand( let setup = setup.subcommand(
SubCommand::with_name("export") App::new("export")
.display_order(4) .display_order(4)
.about("Export an existing database into a SQL script") .about("Export an existing database into a SQL script")
.arg( .arg(
Arg::with_name("file") Arg::new("file")
.index(1) .index(1)
.required(true) .required(true)
.validator(file_valid) .validator(file_valid)
.help("Path to the sql file to export"), .help("Path to the sql file to export"),
) )
.arg( .arg(
Arg::with_name("ns") Arg::new("ns")
.long("ns") .long("ns")
.required(true) .required(true)
.empty_values(false) .forbid_empty_values(true)
.help("The namespace to export the data from"), .help("The namespace to export the data from"),
) )
.arg( .arg(
Arg::with_name("db") Arg::new("db")
.long("db") .long("db")
.required(true) .required(true)
.empty_values(false) .forbid_empty_values(true)
.help("The database to export the data from"), .help("The database to export the data from"),
) )
.arg( .arg(
Arg::with_name("conn") Arg::new("conn")
.short("c") .short('c')
.long("conn") .long("conn")
.empty_values(false) .forbid_empty_values(true)
.validator(conn_valid) .validator(conn_valid)
.default_value("https://surreal.io") .default_value("https://surreal.io")
.help("Remote database server url to connect to"), .help("Remote database server url to connect to"),
) )
.arg( .arg(
Arg::with_name("user") Arg::new("user")
.short("u") .short('u')
.long("user") .long("user")
.empty_values(false) .forbid_empty_values(true)
.default_value("root") .default_value("root")
.help("Database authentication username to use when connecting"), .help("Database authentication username to use when connecting"),
) )
.arg( .arg(
Arg::with_name("pass") Arg::new("pass")
.short("p") .short('p')
.long("pass") .long("pass")
.empty_values(false) .forbid_empty_values(true)
.default_value("root") .default_value("root")
.help("Database authentication password to use when connecting"), .help("Database authentication password to use when connecting"),
), ),
); );
let setup = setup.subcommand( let setup = setup.subcommand(
SubCommand::with_name("version") App::new("version")
.display_order(5) .display_order(5)
.about("Output the command-line tool version information"), .about("Output the command-line tool version information"),
); );
@ -382,11 +382,11 @@ pub fn init() {
log::init(verbose); log::init(verbose);
let output = match matches.subcommand() { let output = match matches.subcommand() {
("start", Some(m)) => start::init(m), Some(("start", m)) => start::init(m),
("backup", Some(m)) => backup::init(m), Some(("backup", m)) => backup::init(m),
("import", Some(m)) => import::init(m), Some(("import", m)) => import::init(m),
("export", Some(m)) => export::init(m), Some(("export", m)) => export::init(m),
("version", Some(m)) => version::init(m), Some(("version", m)) => version::init(m),
_ => Ok(()), _ => Ok(()),
}; };

View file

@ -118,6 +118,7 @@ fn custom(i: &str) -> IResult<&str, (Tables, Option<Value>, Option<Idiom>)> {
let (i, w) = what(i)?; let (i, w) = what(i)?;
let (i, c) = opt(cond)(i)?; let (i, c) = opt(cond)(i)?;
let (i, a) = opt(alias)(i)?; let (i, a) = opt(alias)(i)?;
let (i, _) = mightbespace(i)?;
let (i, _) = tag(")")(i)?; let (i, _) = tag(")")(i)?;
Ok((i, (w, c, a))) Ok((i, (w, c, a)))
} }
@ -195,6 +196,15 @@ mod tests {
#[test] #[test]
fn graph_conditions() { 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 sql = "->(likes, follows WHERE influencer = true AS connections)";
let res = graph(sql); let res = graph(sql);
assert!(res.is_ok()); assert!(res.is_ok());

View file

@ -3,7 +3,7 @@ use dec::prelude::FromPrimitive;
use dec::prelude::ToPrimitive; use dec::prelude::ToPrimitive;
use dec::Decimal; use dec::Decimal;
use dec::MathematicalOps; use dec::MathematicalOps;
use nom::number::complete::double; use nom::number::complete::recognize_float;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::cmp::Ordering; use std::cmp::Ordering;
use std::fmt; 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 { impl From<isize> for Number {
fn from(i: isize) -> Self { fn from(i: isize) -> Self {
Number::Decimal(Decimal::from(i)) 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 { impl From<usize> for Number {
fn from(i: usize) -> Self { fn from(i: usize) -> Self {
Number::Decimal(Decimal::from(i)) Number::Decimal(Decimal::from(i))
@ -87,25 +99,31 @@ impl From<usize> for Number {
impl From<f32> for Number { impl From<f32> for Number {
fn from(f: f32) -> Self { 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 { impl From<f64> for Number {
fn from(f: f64) -> Self { 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 { impl<'a> From<&'a str> for Number {
fn from(s: &str) -> Self { 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 { impl From<String> for Number {
fn from(s: String) -> Self { 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> { pub fn number(i: &str) -> IResult<&str, Number> {
let (i, v) = double(i)?; let (i, v) = recognize_float(i)?;
Ok((i, Number::from(v))) Ok((i, Number::from(v)))
} }

View file

@ -112,7 +112,6 @@ mod tests {
tags[$].value, tags[$].value,
3s as duration, 3s as duration,
1.345 AS number, 1.345 AS number,
-999999999999999.9999999 AS double,
test AS `some thing`, test AS `some thing`,
'2012-04-23T18:25:43.511Z' AS utctime, '2012-04-23T18:25:43.511Z' AS utctime,
'2012-04-23T18:25:43.511-08:00' AS pacifictime, '2012-04-23T18:25:43.511-08:00' AS pacifictime,

View file

@ -125,7 +125,6 @@ mod tests {
fn update_statement() { fn update_statement() {
let sql = "UPDATE test"; let sql = "UPDATE test";
let res = update(sql); let res = update(sql);
println!("{:?}", res);
assert!(res.is_ok()); assert!(res.is_ok());
let out = res.unwrap().1; let out = res.unwrap().1;
assert_eq!("UPDATE test", format!("{}", out)) assert_eq!("UPDATE test", format!("{}", out))