[import] Support SurrealCS on the import command ()

This commit is contained in:
Salvador Girones Gil 2024-09-06 14:45:28 +02:00 committed by GitHub
parent d2b2622a8f
commit bb1884d56b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 90 additions and 56 deletions
core/src
src/cli/validator

View file

@ -51,7 +51,7 @@ async fn migrate_ns_tokens(tx: Arc<Transaction>, ns: &str) -> Result<(), Error>
// We suffix the last id with a null byte, to prevent scanning it twice (which would result in an infinite loop) // We suffix the last id with a null byte, to prevent scanning it twice (which would result in an infinite loop)
beg.clone_from(keys.last().unwrap()); beg.clone_from(keys.last().unwrap());
beg.extend_from_slice(&[b'\0']); beg.extend_from_slice(b"\0");
// Assign to queue // Assign to queue
queue.append(&mut keys); queue.append(&mut keys);
@ -97,7 +97,7 @@ async fn migrate_db_tokens(tx: Arc<Transaction>, ns: &str, db: &str) -> Result<(
// We suffix the last id with a null byte, to prevent scanning it twice (which would result in an infinite loop) // We suffix the last id with a null byte, to prevent scanning it twice (which would result in an infinite loop)
beg.clone_from(keys.last().unwrap()); beg.clone_from(keys.last().unwrap());
beg.extend_from_slice(&[b'\0']); beg.extend_from_slice(b"\0");
// Assign to queue // Assign to queue
queue.append(&mut keys); queue.append(&mut keys);
@ -147,7 +147,7 @@ async fn collect_db_scope_keys(
// We suffix the last id with a null byte, to prevent scanning it twice (which would result in an infinite loop) // We suffix the last id with a null byte, to prevent scanning it twice (which would result in an infinite loop)
beg.clone_from(keys.last().unwrap()); beg.clone_from(keys.last().unwrap());
beg.extend_from_slice(&[b'\0']); beg.extend_from_slice(b"\0");
// Assign to queue // Assign to queue
queue.append(&mut keys); queue.append(&mut keys);
@ -212,7 +212,7 @@ async fn migrate_sc_tokens(
// We suffix the last id with a null byte, to prevent scanning it twice (which would result in an infinite loop) // We suffix the last id with a null byte, to prevent scanning it twice (which would result in an infinite loop)
beg.clone_from(keys.last().unwrap()); beg.clone_from(keys.last().unwrap());
beg.extend_from_slice(&[b'\0']); beg.extend_from_slice(b"\0");
// Assign to queue // Assign to queue
queue.append(&mut keys); queue.append(&mut keys);

View file

@ -111,13 +111,20 @@ impl Method {
matches!( matches!(
self, self,
Method::Ping Method::Ping
| Method::Info | Method::Select | Method::Info
| Method::Insert | Method::Create | Method::Select
| Method::Update | Method::Upsert | Method::Insert
| Method::Merge | Method::Patch | Method::Create
| Method::Delete | Method::Version | Method::Update
| Method::Query | Method::Relate | Method::Upsert
| Method::Run | Method::GraphQL | Method::Merge
| Method::Patch
| Method::Delete
| Method::Version
| Method::Query
| Method::Relate
| Method::Run
| Method::GraphQL
| Method::InsertRelation | Method::InsertRelation
| Method::Unknown | Method::Unknown
) )

View file

@ -2828,9 +2828,11 @@ impl Value {
matches!( matches!(
self, self,
Value::None Value::None
| Value::Null | Value::Array(_) | Value::Null
| Value::Array(_)
| Value::Block(_) | Value::Block(_)
| Value::Bool(_) | Value::Datetime(_) | Value::Bool(_)
| Value::Datetime(_)
| Value::Duration(_) | Value::Duration(_)
| Value::Geometry(_) | Value::Geometry(_)
| Value::Number(_) | Value::Number(_)

View file

@ -745,13 +745,17 @@ impl Parser<'_> {
matches!( matches!(
kind, kind,
t!("ANALYZE") t!("ANALYZE")
| t!("BEGIN") | t!("BREAK") | t!("BEGIN")
| t!("CANCEL") | t!("COMMIT") | t!("BREAK")
| t!("CONTINUE") | t!("FOR") | t!("CANCEL")
| t!("INFO") | t!("KILL") | t!("COMMIT")
| t!("LIVE") | t!("OPTION") | t!("CONTINUE")
| t!("FOR") | t!("INFO")
| t!("KILL") | t!("LIVE")
| t!("OPTION")
| t!("LET") | t!("SHOW") | t!("LET") | t!("SHOW")
| t!("SLEEP") | t!("THROW") | t!("SLEEP")
| t!("THROW")
| t!("USE") | t!("USE")
) )
} }
@ -893,15 +897,17 @@ impl Parser<'_> {
t, t,
t!("NONE") t!("NONE")
| t!("NULL") | t!("true") | t!("NULL") | t!("true")
| t!("false") | t!("r\"") | t!("false")
| t!("r'") | t!("d\"") | t!("r\"") | t!("r'")
| t!("d'") | t!("u\"") | t!("d\"") | t!("d'")
| t!("u'") | t!("\"") | t!("u\"") | t!("u'")
| t!("'") | t!("+") | t!("\"") | t!("'")
| t!("-") | TokenKind::Number(_) | t!("+") | t!("-")
| TokenKind::Number(_)
| TokenKind::Digits | TokenKind::Digits
| TokenKind::Duration | TokenKind::Duration
| TokenKind::NaN | t!("$param") | TokenKind::NaN
| t!("$param")
| t!("[") | t!("{") | t!("[") | t!("{")
| t!("(") | TokenKind::Keyword(_) | t!("(") | TokenKind::Keyword(_)
| TokenKind::Language(_) | TokenKind::Language(_)
@ -915,10 +921,14 @@ impl Parser<'_> {
| TokenKind::DurationSuffix( | TokenKind::DurationSuffix(
// All except Micro unicode // All except Micro unicode
DurationSuffix::Nano DurationSuffix::Nano
| DurationSuffix::Micro | DurationSuffix::Milli | DurationSuffix::Micro
| DurationSuffix::Second | DurationSuffix::Minute | DurationSuffix::Milli
| DurationSuffix::Hour | DurationSuffix::Day | DurationSuffix::Second
| DurationSuffix::Week | DurationSuffix::Year | DurationSuffix::Minute
| DurationSuffix::Hour
| DurationSuffix::Day
| DurationSuffix::Week
| DurationSuffix::Year
) )
) )
} }

View file

@ -78,20 +78,30 @@ impl Parser<'_> {
matches!( matches!(
kind, kind,
t!("ACCESS") t!("ACCESS")
| t!("ALTER") | t!("ANALYZE") | t!("ALTER")
| t!("BEGIN") | t!("BREAK") | t!("ANALYZE")
| t!("CANCEL") | t!("COMMIT") | t!("BEGIN")
| t!("CONTINUE") | t!("CREATE") | t!("BREAK")
| t!("DEFINE") | t!("DELETE") | t!("CANCEL")
| t!("COMMIT")
| t!("CONTINUE")
| t!("CREATE")
| t!("DEFINE")
| t!("DELETE")
| t!("FOR") | t!("IF") | t!("FOR") | t!("IF")
| t!("INFO") | t!("INSERT") | t!("INFO") | t!("INSERT")
| t!("KILL") | t!("LIVE") | t!("KILL") | t!("LIVE")
| t!("OPTION") | t!("REBUILD") | t!("OPTION")
| t!("RETURN") | t!("RELATE") | t!("REBUILD")
| t!("REMOVE") | t!("SELECT") | t!("RETURN")
| t!("RELATE")
| t!("REMOVE")
| t!("SELECT")
| t!("LET") | t!("SHOW") | t!("LET") | t!("SHOW")
| t!("SLEEP") | t!("THROW") | t!("SLEEP")
| t!("UPDATE") | t!("UPSERT") | t!("THROW")
| t!("UPDATE")
| t!("UPSERT")
| t!("USE") | t!("USE")
) )
} }

View file

@ -30,10 +30,14 @@ impl Parser<'_> {
| TokenKind::DurationSuffix( | TokenKind::DurationSuffix(
// All except Micro unicode // All except Micro unicode
DurationSuffix::Nano DurationSuffix::Nano
| DurationSuffix::Micro | DurationSuffix::Milli | DurationSuffix::Micro
| DurationSuffix::Second | DurationSuffix::Minute | DurationSuffix::Milli
| DurationSuffix::Hour | DurationSuffix::Day | DurationSuffix::Second
| DurationSuffix::Week | DurationSuffix::Year | DurationSuffix::Minute
| DurationSuffix::Hour
| DurationSuffix::Day
| DurationSuffix::Week
| DurationSuffix::Year
) )
) )
} }
@ -51,17 +55,18 @@ impl Parser<'_> {
| TokenKind::DatetimeChars(_) | TokenKind::DatetimeChars(_)
| TokenKind::Exponent | TokenKind::Exponent
| TokenKind::NumberSuffix(_) | TokenKind::NumberSuffix(_)
| TokenKind::NaN | TokenKind::DurationSuffix( | TokenKind::NaN
// All except Micro unicode | TokenKind::DurationSuffix(
DurationSuffix::Nano // All except Micro unicode
| DurationSuffix::Micro DurationSuffix::Nano
| DurationSuffix::Milli | DurationSuffix::Micro
| DurationSuffix::Second | DurationSuffix::Milli
| DurationSuffix::Minute | DurationSuffix::Second
| DurationSuffix::Hour | DurationSuffix::Minute
| DurationSuffix::Day | DurationSuffix::Hour
| DurationSuffix::Week | DurationSuffix::Day
) | DurationSuffix::Week
)
) )
} }

View file

@ -60,7 +60,7 @@ pub(crate) fn endpoint_valid(v: &str) -> Result<String, String> {
let scheme = split_endpoint(v).0; let scheme = split_endpoint(v).0;
match scheme { match scheme {
"http" | "https" | "ws" | "wss" | "fdb" | "mem" | "rocksdb" | "surrealkv" | "file" "http" | "https" | "ws" | "wss" | "fdb" | "mem" | "rocksdb" | "surrealkv" | "file"
| "tikv" => Ok(v.to_string()), | "surrealcs" | "tikv" => Ok(v.to_string()),
_ => Err(String::from("Provide a valid database connection string")), _ => Err(String::from("Provide a valid database connection string")),
} }
} }