Allow memory
as an address endpoint in CLI sql
command (#1563)
This commit is contained in:
parent
7c199ff586
commit
a24bb4f4b8
3 changed files with 19 additions and 8 deletions
|
@ -115,8 +115,12 @@ pub trait IntoEndpoint {
|
||||||
|
|
||||||
impl IntoEndpoint for &str {
|
impl IntoEndpoint for &str {
|
||||||
fn into_endpoint(self) -> Result<Endpoint> {
|
fn into_endpoint(self) -> Result<Endpoint> {
|
||||||
|
let url = match self {
|
||||||
|
"memory" => "mem://",
|
||||||
|
_ => self,
|
||||||
|
};
|
||||||
Ok(Endpoint {
|
Ok(Endpoint {
|
||||||
endpoint: Url::parse(self).map_err(|_| Error::InvalidUrl(self.to_owned()))?,
|
endpoint: Url::parse(url).map_err(|_| Error::InvalidUrl(self.to_owned()))?,
|
||||||
strict: false,
|
strict: false,
|
||||||
#[cfg(any(feature = "native-tls", feature = "rustls"))]
|
#[cfg(any(feature = "native-tls", feature = "rustls"))]
|
||||||
tls_config: None,
|
tls_config: None,
|
||||||
|
@ -132,12 +136,7 @@ impl IntoEndpoint for &String {
|
||||||
|
|
||||||
impl IntoEndpoint for String {
|
impl IntoEndpoint for String {
|
||||||
fn into_endpoint(self) -> Result<Endpoint> {
|
fn into_endpoint(self) -> Result<Endpoint> {
|
||||||
Ok(Endpoint {
|
self.as_str().into_endpoint()
|
||||||
endpoint: Url::parse(&self).map_err(|_| Error::InvalidUrl(self))?,
|
|
||||||
strict: false,
|
|
||||||
#[cfg(any(feature = "native-tls", feature = "rustls"))]
|
|
||||||
tls_config: None,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,6 +93,7 @@ mod http {
|
||||||
#[cfg(feature = "kv-mem")]
|
#[cfg(feature = "kv-mem")]
|
||||||
mod mem {
|
mod mem {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use surrealdb::engines::any;
|
||||||
use surrealdb::engines::local::Db;
|
use surrealdb::engines::local::Db;
|
||||||
use surrealdb::engines::local::Mem;
|
use surrealdb::engines::local::Mem;
|
||||||
|
|
||||||
|
@ -100,6 +101,11 @@ mod mem {
|
||||||
Surreal::new::<Mem>(()).await.unwrap()
|
Surreal::new::<Mem>(()).await.unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn memory_allowed_as_address() {
|
||||||
|
any::connect("memory").await.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
include!("api/mod.rs");
|
include!("api/mod.rs");
|
||||||
include!("api/backup.rs");
|
include!("api/backup.rs");
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,13 @@ We would love it if you could star the repository (https://github.com/surrealdb/
|
||||||
";
|
";
|
||||||
|
|
||||||
fn split_endpoint(v: &str) -> (&str, &str) {
|
fn split_endpoint(v: &str) -> (&str, &str) {
|
||||||
v.split_once("://").unwrap_or_default()
|
match v {
|
||||||
|
"memory" => ("mem", ""),
|
||||||
|
v => match v.split_once("://") {
|
||||||
|
Some(parts) => parts,
|
||||||
|
None => v.split_once(':').unwrap_or_default(),
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn file_valid(v: &str) -> Result<(), String> {
|
fn file_valid(v: &str) -> Result<(), String> {
|
||||||
|
|
Loading…
Reference in a new issue