2022-07-28 21:40:38 +00:00
|
|
|
mod parse;
|
|
|
|
use parse::Parse;
|
2022-12-30 08:23:19 +00:00
|
|
|
use surrealdb::dbs::Session;
|
|
|
|
use surrealdb::err::Error;
|
|
|
|
use surrealdb::kvs::Datastore;
|
2022-07-28 21:40:38 +00:00
|
|
|
use surrealdb::sql::Value;
|
|
|
|
|
|
|
|
#[tokio::test]
|
|
|
|
async fn define_statement_namespace() -> Result<(), Error> {
|
|
|
|
let sql = "
|
|
|
|
DEFINE NAMESPACE test;
|
|
|
|
INFO FOR KV;
|
|
|
|
";
|
|
|
|
let dbs = Datastore::new("memory").await?;
|
|
|
|
let ses = Session::for_kv().with_ns("test").with_db("test");
|
|
|
|
let res = &mut dbs.execute(&sql, &ses, None, false).await?;
|
|
|
|
assert_eq!(res.len(), 2);
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
|
|
|
let val = Value::parse(
|
|
|
|
"{
|
|
|
|
ns: { test: 'DEFINE NAMESPACE test' },
|
|
|
|
}",
|
|
|
|
);
|
|
|
|
assert_eq!(tmp, val);
|
|
|
|
//
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[tokio::test]
|
|
|
|
async fn define_statement_database() -> Result<(), Error> {
|
|
|
|
let sql = "
|
|
|
|
DEFINE DATABASE test;
|
|
|
|
INFO FOR NS;
|
|
|
|
";
|
|
|
|
let dbs = Datastore::new("memory").await?;
|
|
|
|
let ses = Session::for_kv().with_ns("test").with_db("test");
|
|
|
|
let res = &mut dbs.execute(&sql, &ses, None, false).await?;
|
|
|
|
assert_eq!(res.len(), 2);
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
|
|
|
let val = Value::parse(
|
|
|
|
"{
|
|
|
|
db: { test: 'DEFINE DATABASE test' },
|
|
|
|
nl: {},
|
|
|
|
nt: {},
|
|
|
|
}",
|
|
|
|
);
|
|
|
|
assert_eq!(tmp, val);
|
|
|
|
//
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[tokio::test]
|
2023-03-25 19:44:03 +00:00
|
|
|
async fn define_statement_function() -> Result<(), Error> {
|
2022-07-28 21:40:38 +00:00
|
|
|
let sql = "
|
2023-03-25 19:44:03 +00:00
|
|
|
DEFINE FUNCTION fn::test($first: string, $last: string) {
|
|
|
|
RETURN $first + $last;
|
|
|
|
};
|
2022-07-28 21:40:38 +00:00
|
|
|
INFO FOR DB;
|
|
|
|
";
|
|
|
|
let dbs = Datastore::new("memory").await?;
|
|
|
|
let ses = Session::for_kv().with_ns("test").with_db("test");
|
|
|
|
let res = &mut dbs.execute(&sql, &ses, None, false).await?;
|
|
|
|
assert_eq!(res.len(), 2);
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
|
|
|
let val = Value::parse(
|
|
|
|
"{
|
|
|
|
dl: {},
|
|
|
|
dt: {},
|
2023-03-25 19:44:03 +00:00
|
|
|
fc: { test: 'DEFINE FUNCTION fn::test($first: string, $last: string) { RETURN $first + $last; }' },
|
|
|
|
pa: {},
|
|
|
|
sc: {},
|
2023-01-09 12:43:47 +00:00
|
|
|
pa: {},
|
|
|
|
sc: {},
|
2023-03-25 19:44:03 +00:00
|
|
|
tb: {},
|
|
|
|
}",
|
|
|
|
);
|
|
|
|
assert_eq!(tmp, val);
|
|
|
|
//
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[tokio::test]
|
|
|
|
async fn define_statement_table_drop() -> Result<(), Error> {
|
|
|
|
let sql = "
|
|
|
|
DEFINE TABLE test DROP;
|
|
|
|
INFO FOR DB;
|
|
|
|
";
|
|
|
|
let dbs = Datastore::new("memory").await?;
|
|
|
|
let ses = Session::for_kv().with_ns("test").with_db("test");
|
|
|
|
let res = &mut dbs.execute(&sql, &ses, None, false).await?;
|
|
|
|
assert_eq!(res.len(), 2);
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
|
|
|
let val = Value::parse(
|
|
|
|
"{
|
|
|
|
dl: {},
|
|
|
|
dt: {},
|
|
|
|
fc: {},
|
2023-01-09 12:43:47 +00:00
|
|
|
pa: {},
|
2022-07-28 21:40:38 +00:00
|
|
|
sc: {},
|
|
|
|
tb: { test: 'DEFINE TABLE test DROP SCHEMALESS' },
|
|
|
|
}",
|
|
|
|
);
|
|
|
|
assert_eq!(tmp, val);
|
|
|
|
//
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[tokio::test]
|
|
|
|
async fn define_statement_table_schemaless() -> Result<(), Error> {
|
|
|
|
let sql = "
|
|
|
|
DEFINE TABLE test SCHEMALESS;
|
|
|
|
INFO FOR DB;
|
|
|
|
";
|
|
|
|
let dbs = Datastore::new("memory").await?;
|
|
|
|
let ses = Session::for_kv().with_ns("test").with_db("test");
|
|
|
|
let res = &mut dbs.execute(&sql, &ses, None, false).await?;
|
|
|
|
assert_eq!(res.len(), 2);
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
|
|
|
let val = Value::parse(
|
|
|
|
"{
|
|
|
|
dl: {},
|
|
|
|
dt: {},
|
2023-03-25 19:44:03 +00:00
|
|
|
fc: {},
|
2023-01-09 12:43:47 +00:00
|
|
|
pa: {},
|
2022-07-28 21:40:38 +00:00
|
|
|
sc: {},
|
|
|
|
tb: { test: 'DEFINE TABLE test SCHEMALESS' },
|
|
|
|
}",
|
|
|
|
);
|
|
|
|
assert_eq!(tmp, val);
|
|
|
|
//
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[tokio::test]
|
|
|
|
async fn define_statement_table_schemafull() -> Result<(), Error> {
|
|
|
|
let sql = "
|
2022-09-20 07:11:14 +00:00
|
|
|
DEFINE TABLE test SCHEMAFUL;
|
2022-07-28 21:40:38 +00:00
|
|
|
DEFINE TABLE test SCHEMAFULL;
|
|
|
|
INFO FOR DB;
|
|
|
|
";
|
|
|
|
let dbs = Datastore::new("memory").await?;
|
|
|
|
let ses = Session::for_kv().with_ns("test").with_db("test");
|
|
|
|
let res = &mut dbs.execute(&sql, &ses, None, false).await?;
|
2022-09-20 07:11:14 +00:00
|
|
|
assert_eq!(res.len(), 3);
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
2022-07-28 21:40:38 +00:00
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
|
|
|
let val = Value::parse(
|
|
|
|
"{
|
|
|
|
dl: {},
|
|
|
|
dt: {},
|
2023-03-25 19:44:03 +00:00
|
|
|
fc: {},
|
2023-01-09 12:43:47 +00:00
|
|
|
pa: {},
|
2022-07-28 21:40:38 +00:00
|
|
|
sc: {},
|
|
|
|
tb: { test: 'DEFINE TABLE test SCHEMAFULL' },
|
|
|
|
}",
|
|
|
|
);
|
|
|
|
assert_eq!(tmp, val);
|
|
|
|
//
|
|
|
|
Ok(())
|
2022-09-11 08:08:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[tokio::test]
|
|
|
|
async fn define_statement_table_schemaful() -> Result<(), Error> {
|
|
|
|
let sql = "
|
|
|
|
DEFINE TABLE test SCHEMAFUL;
|
|
|
|
INFO FOR DB;
|
|
|
|
";
|
|
|
|
let dbs = Datastore::new("memory").await?;
|
|
|
|
let ses = Session::for_kv().with_ns("test").with_db("test");
|
|
|
|
let res = &mut dbs.execute(&sql, &ses, None, false).await?;
|
|
|
|
assert_eq!(res.len(), 2);
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
|
|
|
let val = Value::parse(
|
|
|
|
"{
|
|
|
|
dl: {},
|
|
|
|
dt: {},
|
2023-03-25 19:44:03 +00:00
|
|
|
fc: {},
|
2023-01-09 12:43:47 +00:00
|
|
|
pa: {},
|
2022-09-11 08:08:36 +00:00
|
|
|
sc: {},
|
|
|
|
tb: { test: 'DEFINE TABLE test SCHEMAFULL' },
|
|
|
|
}",
|
|
|
|
);
|
|
|
|
assert_eq!(tmp, val);
|
|
|
|
//
|
|
|
|
Ok(())
|
2022-07-28 21:40:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[tokio::test]
|
|
|
|
async fn define_statement_event() -> Result<(), Error> {
|
|
|
|
let sql = "
|
|
|
|
DEFINE EVENT test ON user WHEN true THEN (
|
|
|
|
CREATE activity SET user = $this, value = $after.email, action = $event
|
|
|
|
);
|
|
|
|
DEFINE EVENT test ON TABLE user WHEN true THEN (
|
|
|
|
CREATE activity SET user = $this, value = $after.email, action = $event
|
|
|
|
);
|
|
|
|
INFO FOR TABLE user;
|
|
|
|
UPDATE user:test SET email = 'info@surrealdb.com', updated_at = time::now();
|
|
|
|
UPDATE user:test SET email = 'info@surrealdb.com', updated_at = time::now();
|
|
|
|
UPDATE user:test SET email = 'test@surrealdb.com', updated_at = time::now();
|
2023-01-08 17:11:35 +00:00
|
|
|
SELECT count() FROM activity GROUP ALL;
|
2022-07-28 21:40:38 +00:00
|
|
|
";
|
|
|
|
let dbs = Datastore::new("memory").await?;
|
|
|
|
let ses = Session::for_kv().with_ns("test").with_db("test");
|
|
|
|
let res = &mut dbs.execute(&sql, &ses, None, false).await?;
|
|
|
|
assert_eq!(res.len(), 7);
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
|
|
|
let val = Value::parse(
|
|
|
|
"{
|
|
|
|
ev: { test: 'DEFINE EVENT test ON user WHEN true THEN (CREATE activity SET user = $this, value = $after.email, action = $event)' },
|
|
|
|
fd: {},
|
|
|
|
ft: {},
|
|
|
|
ix: {},
|
|
|
|
}",
|
|
|
|
);
|
|
|
|
assert_eq!(tmp, val);
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
|
|
|
let val = Value::parse(
|
|
|
|
"[{
|
|
|
|
count: 3
|
|
|
|
}]",
|
|
|
|
);
|
|
|
|
assert_eq!(tmp, val);
|
|
|
|
//
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[tokio::test]
|
|
|
|
async fn define_statement_event_when_event() -> Result<(), Error> {
|
|
|
|
let sql = "
|
|
|
|
DEFINE EVENT test ON user WHEN $event = 'CREATE' THEN (
|
|
|
|
CREATE activity SET user = $this, value = $after.email, action = $event
|
|
|
|
);
|
|
|
|
DEFINE EVENT test ON TABLE user WHEN $event = 'CREATE' THEN (
|
|
|
|
CREATE activity SET user = $this, value = $after.email, action = $event
|
|
|
|
);
|
|
|
|
INFO FOR TABLE user;
|
|
|
|
UPDATE user:test SET email = 'info@surrealdb.com', updated_at = time::now();
|
|
|
|
UPDATE user:test SET email = 'info@surrealdb.com', updated_at = time::now();
|
|
|
|
UPDATE user:test SET email = 'test@surrealdb.com', updated_at = time::now();
|
2023-01-08 17:11:35 +00:00
|
|
|
SELECT count() FROM activity GROUP ALL;
|
2022-07-28 21:40:38 +00:00
|
|
|
";
|
|
|
|
let dbs = Datastore::new("memory").await?;
|
|
|
|
let ses = Session::for_kv().with_ns("test").with_db("test");
|
|
|
|
let res = &mut dbs.execute(&sql, &ses, None, false).await?;
|
|
|
|
assert_eq!(res.len(), 7);
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
|
|
|
let val = Value::parse(
|
2022-10-19 14:48:50 +00:00
|
|
|
r#"{
|
|
|
|
ev: { test: "DEFINE EVENT test ON user WHEN $event = 'CREATE' THEN (CREATE activity SET user = $this, value = $after.email, action = $event)" },
|
2022-07-28 21:40:38 +00:00
|
|
|
fd: {},
|
|
|
|
ft: {},
|
|
|
|
ix: {},
|
2022-10-19 14:48:50 +00:00
|
|
|
}"#,
|
2022-07-28 21:40:38 +00:00
|
|
|
);
|
|
|
|
assert_eq!(tmp, val);
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
|
|
|
let val = Value::parse(
|
|
|
|
"[{
|
|
|
|
count: 1
|
|
|
|
}]",
|
|
|
|
);
|
|
|
|
assert_eq!(tmp, val);
|
|
|
|
//
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[tokio::test]
|
|
|
|
async fn define_statement_event_when_logic() -> Result<(), Error> {
|
|
|
|
let sql = "
|
|
|
|
DEFINE EVENT test ON user WHEN $before.email != $after.email THEN (
|
|
|
|
CREATE activity SET user = $this, value = $after.email, action = $event
|
|
|
|
);
|
|
|
|
DEFINE EVENT test ON TABLE user WHEN $before.email != $after.email THEN (
|
|
|
|
CREATE activity SET user = $this, value = $after.email, action = $event
|
|
|
|
);
|
|
|
|
INFO FOR TABLE user;
|
|
|
|
UPDATE user:test SET email = 'info@surrealdb.com', updated_at = time::now();
|
|
|
|
UPDATE user:test SET email = 'info@surrealdb.com', updated_at = time::now();
|
|
|
|
UPDATE user:test SET email = 'test@surrealdb.com', updated_at = time::now();
|
2023-01-08 17:11:35 +00:00
|
|
|
SELECT count() FROM activity GROUP ALL;
|
2022-07-28 21:40:38 +00:00
|
|
|
";
|
|
|
|
let dbs = Datastore::new("memory").await?;
|
|
|
|
let ses = Session::for_kv().with_ns("test").with_db("test");
|
|
|
|
let res = &mut dbs.execute(&sql, &ses, None, false).await?;
|
|
|
|
assert_eq!(res.len(), 7);
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
|
|
|
let val = Value::parse(
|
|
|
|
"{
|
|
|
|
ev: { test: 'DEFINE EVENT test ON user WHEN $before.email != $after.email THEN (CREATE activity SET user = $this, value = $after.email, action = $event)' },
|
|
|
|
fd: {},
|
|
|
|
ft: {},
|
|
|
|
ix: {},
|
|
|
|
}",
|
|
|
|
);
|
|
|
|
assert_eq!(tmp, val);
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
|
|
|
let val = Value::parse(
|
|
|
|
"[{
|
|
|
|
count: 2
|
|
|
|
}]",
|
|
|
|
);
|
|
|
|
assert_eq!(tmp, val);
|
|
|
|
//
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[tokio::test]
|
|
|
|
async fn define_statement_field() -> Result<(), Error> {
|
|
|
|
let sql = "
|
|
|
|
DEFINE FIELD test ON user;
|
|
|
|
DEFINE FIELD test ON TABLE user;
|
|
|
|
INFO FOR TABLE user;
|
|
|
|
";
|
|
|
|
let dbs = Datastore::new("memory").await?;
|
|
|
|
let ses = Session::for_kv().with_ns("test").with_db("test");
|
|
|
|
let res = &mut dbs.execute(&sql, &ses, None, false).await?;
|
|
|
|
assert_eq!(res.len(), 3);
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
|
|
|
let val = Value::parse(
|
|
|
|
"{
|
|
|
|
ev: {},
|
|
|
|
fd: { test: 'DEFINE FIELD test ON user' },
|
|
|
|
ft: {},
|
|
|
|
ix: {},
|
|
|
|
}",
|
|
|
|
);
|
|
|
|
assert_eq!(tmp, val);
|
|
|
|
//
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[tokio::test]
|
|
|
|
async fn define_statement_field_type() -> Result<(), Error> {
|
|
|
|
let sql = "
|
|
|
|
DEFINE FIELD test ON user TYPE string;
|
|
|
|
DEFINE FIELD test ON TABLE user TYPE string;
|
|
|
|
INFO FOR TABLE user;
|
|
|
|
";
|
|
|
|
let dbs = Datastore::new("memory").await?;
|
|
|
|
let ses = Session::for_kv().with_ns("test").with_db("test");
|
|
|
|
let res = &mut dbs.execute(&sql, &ses, None, false).await?;
|
|
|
|
assert_eq!(res.len(), 3);
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
|
|
|
let val = Value::parse(
|
|
|
|
"{
|
|
|
|
ev: {},
|
|
|
|
fd: { test: 'DEFINE FIELD test ON user TYPE string' },
|
|
|
|
ft: {},
|
|
|
|
ix: {},
|
|
|
|
}",
|
|
|
|
);
|
|
|
|
assert_eq!(tmp, val);
|
|
|
|
//
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[tokio::test]
|
|
|
|
async fn define_statement_field_value() -> Result<(), Error> {
|
|
|
|
let sql = "
|
|
|
|
DEFINE FIELD test ON user VALUE $value OR 'GBR';
|
|
|
|
DEFINE FIELD test ON TABLE user VALUE $value OR 'GBR';
|
|
|
|
INFO FOR TABLE user;
|
|
|
|
";
|
|
|
|
let dbs = Datastore::new("memory").await?;
|
|
|
|
let ses = Session::for_kv().with_ns("test").with_db("test");
|
|
|
|
let res = &mut dbs.execute(&sql, &ses, None, false).await?;
|
|
|
|
assert_eq!(res.len(), 3);
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
|
|
|
let val = Value::parse(
|
2022-10-19 14:48:50 +00:00
|
|
|
r#"{
|
2022-07-28 21:40:38 +00:00
|
|
|
ev: {},
|
2022-10-19 14:48:50 +00:00
|
|
|
fd: { test: "DEFINE FIELD test ON user VALUE $value OR 'GBR'" },
|
2022-07-28 21:40:38 +00:00
|
|
|
ft: {},
|
|
|
|
ix: {},
|
2022-10-19 14:48:50 +00:00
|
|
|
}"#,
|
2022-07-28 21:40:38 +00:00
|
|
|
);
|
|
|
|
assert_eq!(tmp, val);
|
|
|
|
//
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[tokio::test]
|
|
|
|
async fn define_statement_field_assert() -> Result<(), Error> {
|
|
|
|
let sql = "
|
|
|
|
DEFINE FIELD test ON user ASSERT $value != NONE AND $value = /[A-Z]{3}/;
|
|
|
|
DEFINE FIELD test ON TABLE user ASSERT $value != NONE AND $value = /[A-Z]{3}/;
|
|
|
|
INFO FOR TABLE user;
|
|
|
|
";
|
|
|
|
let dbs = Datastore::new("memory").await?;
|
|
|
|
let ses = Session::for_kv().with_ns("test").with_db("test");
|
|
|
|
let res = &mut dbs.execute(&sql, &ses, None, false).await?;
|
|
|
|
assert_eq!(res.len(), 3);
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
|
|
|
let val = Value::parse(
|
|
|
|
"{
|
|
|
|
ev: {},
|
|
|
|
fd: { test: 'DEFINE FIELD test ON user ASSERT $value != NONE AND $value = /[A-Z]{3}/' },
|
|
|
|
ft: {},
|
|
|
|
ix: {},
|
|
|
|
}",
|
|
|
|
);
|
|
|
|
assert_eq!(tmp, val);
|
|
|
|
//
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[tokio::test]
|
|
|
|
async fn define_statement_field_type_value_assert() -> Result<(), Error> {
|
|
|
|
let sql = "
|
|
|
|
DEFINE FIELD test ON user TYPE string VALUE $value OR 'GBR' ASSERT $value != NONE AND $value = /[A-Z]{3}/;
|
|
|
|
DEFINE FIELD test ON TABLE user TYPE string VALUE $value OR 'GBR' ASSERT $value != NONE AND $value = /[A-Z]{3}/;
|
|
|
|
INFO FOR TABLE user;
|
|
|
|
";
|
|
|
|
let dbs = Datastore::new("memory").await?;
|
|
|
|
let ses = Session::for_kv().with_ns("test").with_db("test");
|
|
|
|
let res = &mut dbs.execute(&sql, &ses, None, false).await?;
|
|
|
|
assert_eq!(res.len(), 3);
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
|
|
|
let val = Value::parse(
|
2022-10-19 14:48:50 +00:00
|
|
|
r#"{
|
2022-07-28 21:40:38 +00:00
|
|
|
ev: {},
|
2022-10-19 14:48:50 +00:00
|
|
|
fd: { test: "DEFINE FIELD test ON user TYPE string VALUE $value OR 'GBR' ASSERT $value != NONE AND $value = /[A-Z]{3}/" },
|
2022-07-28 21:40:38 +00:00
|
|
|
ft: {},
|
|
|
|
ix: {},
|
2022-10-19 14:48:50 +00:00
|
|
|
}"#,
|
2022-07-28 21:40:38 +00:00
|
|
|
);
|
|
|
|
assert_eq!(tmp, val);
|
|
|
|
//
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2022-08-25 13:49:33 +00:00
|
|
|
#[tokio::test]
|
|
|
|
async fn define_statement_index_single_simple() -> Result<(), Error> {
|
|
|
|
let sql = "
|
|
|
|
CREATE user:1 SET age = 23;
|
|
|
|
CREATE user:2 SET age = 10;
|
|
|
|
DEFINE INDEX test ON user FIELDS age;
|
|
|
|
DEFINE INDEX test ON user COLUMNS age;
|
|
|
|
INFO FOR TABLE user;
|
|
|
|
UPDATE user:1 SET age = 24;
|
|
|
|
UPDATE user:2 SET age = 11;
|
|
|
|
";
|
|
|
|
let dbs = Datastore::new("memory").await?;
|
|
|
|
let ses = Session::for_kv().with_ns("test").with_db("test");
|
|
|
|
let res = &mut dbs.execute(&sql, &ses, None, false).await?;
|
|
|
|
assert_eq!(res.len(), 7);
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
|
|
|
let val = Value::parse(
|
|
|
|
"{
|
|
|
|
ev: {},
|
|
|
|
fd: {},
|
|
|
|
ft: {},
|
|
|
|
ix: { test: 'DEFINE INDEX test ON user FIELDS age' },
|
|
|
|
}",
|
|
|
|
);
|
|
|
|
assert_eq!(tmp, val);
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
|
|
|
let val = Value::parse("[{ id: user:1, age: 24 }]");
|
|
|
|
assert_eq!(tmp, val);
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
|
|
|
let val = Value::parse("[{ id: user:2, age: 11 }]");
|
|
|
|
assert_eq!(tmp, val);
|
|
|
|
//
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2022-07-28 21:40:38 +00:00
|
|
|
#[tokio::test]
|
|
|
|
async fn define_statement_index_single() -> Result<(), Error> {
|
|
|
|
let sql = "
|
|
|
|
DEFINE INDEX test ON user FIELDS email;
|
|
|
|
DEFINE INDEX test ON user COLUMNS email;
|
|
|
|
INFO FOR TABLE user;
|
|
|
|
CREATE user:1 SET email = 'test@surrealdb.com';
|
|
|
|
CREATE user:2 SET email = 'test@surrealdb.com';
|
|
|
|
";
|
|
|
|
let dbs = Datastore::new("memory").await?;
|
|
|
|
let ses = Session::for_kv().with_ns("test").with_db("test");
|
|
|
|
let res = &mut dbs.execute(&sql, &ses, None, false).await?;
|
|
|
|
assert_eq!(res.len(), 5);
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
|
|
|
let val = Value::parse(
|
|
|
|
"{
|
|
|
|
ev: {},
|
|
|
|
fd: {},
|
|
|
|
ft: {},
|
|
|
|
ix: { test: 'DEFINE INDEX test ON user FIELDS email' },
|
|
|
|
}",
|
|
|
|
);
|
|
|
|
assert_eq!(tmp, val);
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
|
|
|
let val = Value::parse("[{ id: user:1, email: 'test@surrealdb.com' }]");
|
|
|
|
assert_eq!(tmp, val);
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
|
|
|
let val = Value::parse("[{ id: user:2, email: 'test@surrealdb.com' }]");
|
|
|
|
assert_eq!(tmp, val);
|
|
|
|
//
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[tokio::test]
|
|
|
|
async fn define_statement_index_multiple() -> Result<(), Error> {
|
|
|
|
let sql = "
|
|
|
|
DEFINE INDEX test ON user FIELDS account, email;
|
|
|
|
DEFINE INDEX test ON user COLUMNS account, email;
|
|
|
|
INFO FOR TABLE user;
|
|
|
|
CREATE user:1 SET account = 'apple', email = 'test@surrealdb.com';
|
|
|
|
CREATE user:2 SET account = 'tesla', email = 'test@surrealdb.com';
|
|
|
|
CREATE user:3 SET account = 'apple', email = 'test@surrealdb.com';
|
|
|
|
CREATE user:4 SET account = 'tesla', email = 'test@surrealdb.com';
|
|
|
|
";
|
|
|
|
let dbs = Datastore::new("memory").await?;
|
|
|
|
let ses = Session::for_kv().with_ns("test").with_db("test");
|
|
|
|
let res = &mut dbs.execute(&sql, &ses, None, false).await?;
|
|
|
|
assert_eq!(res.len(), 7);
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
|
|
|
let val = Value::parse(
|
|
|
|
"{
|
|
|
|
ev: {},
|
|
|
|
fd: {},
|
|
|
|
ft: {},
|
|
|
|
ix: { test: 'DEFINE INDEX test ON user FIELDS account, email' },
|
|
|
|
}",
|
|
|
|
);
|
|
|
|
assert_eq!(tmp, val);
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
|
|
|
let val = Value::parse("[{ id: user:1, account: 'apple', email: 'test@surrealdb.com' }]");
|
|
|
|
assert_eq!(tmp, val);
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
|
|
|
let val = Value::parse("[{ id: user:2, account: 'tesla', email: 'test@surrealdb.com' }]");
|
|
|
|
assert_eq!(tmp, val);
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
|
|
|
let val = Value::parse("[{ id: user:3, account: 'apple', email: 'test@surrealdb.com' }]");
|
|
|
|
assert_eq!(tmp, val);
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
|
|
|
let val = Value::parse("[{ id: user:4, account: 'tesla', email: 'test@surrealdb.com' }]");
|
|
|
|
assert_eq!(tmp, val);
|
|
|
|
//
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[tokio::test]
|
|
|
|
async fn define_statement_index_single_unique() -> Result<(), Error> {
|
|
|
|
let sql = "
|
|
|
|
DEFINE INDEX test ON user FIELDS email UNIQUE;
|
|
|
|
DEFINE INDEX test ON user COLUMNS email UNIQUE;
|
|
|
|
INFO FOR TABLE user;
|
|
|
|
CREATE user:1 SET email = 'test@surrealdb.com';
|
|
|
|
CREATE user:2 SET email = 'test@surrealdb.com';
|
2022-09-24 17:58:56 +00:00
|
|
|
DELETE user:1;
|
|
|
|
CREATE user:2 SET email = 'test@surrealdb.com';
|
2022-07-28 21:40:38 +00:00
|
|
|
";
|
|
|
|
let dbs = Datastore::new("memory").await?;
|
|
|
|
let ses = Session::for_kv().with_ns("test").with_db("test");
|
|
|
|
let res = &mut dbs.execute(&sql, &ses, None, false).await?;
|
2022-09-24 17:58:56 +00:00
|
|
|
assert_eq!(res.len(), 7);
|
2022-07-28 21:40:38 +00:00
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
|
|
|
let val = Value::parse(
|
|
|
|
"{
|
|
|
|
ev: {},
|
|
|
|
fd: {},
|
|
|
|
ft: {},
|
|
|
|
ix: { test: 'DEFINE INDEX test ON user FIELDS email UNIQUE' },
|
|
|
|
}",
|
|
|
|
);
|
|
|
|
assert_eq!(tmp, val);
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
|
|
|
let val = Value::parse("[{ id: user:1, email: 'test@surrealdb.com' }]");
|
|
|
|
assert_eq!(tmp, val);
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(matches!(
|
|
|
|
tmp.err(),
|
2022-10-19 14:48:50 +00:00
|
|
|
Some(e) if e.to_string() == r#"Database index `test` already contains 'test@surrealdb.com', with record `user:2`"#
|
2022-07-28 21:40:38 +00:00
|
|
|
));
|
|
|
|
//
|
2022-09-24 17:58:56 +00:00
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
|
|
|
let val = Value::parse("[{ id: user:2, email: 'test@surrealdb.com' }]");
|
|
|
|
assert_eq!(tmp, val);
|
|
|
|
//
|
2022-07-28 21:40:38 +00:00
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[tokio::test]
|
|
|
|
async fn define_statement_index_multiple_unique() -> Result<(), Error> {
|
|
|
|
let sql = "
|
|
|
|
DEFINE INDEX test ON user FIELDS account, email UNIQUE;
|
|
|
|
DEFINE INDEX test ON user COLUMNS account, email UNIQUE;
|
|
|
|
INFO FOR TABLE user;
|
|
|
|
CREATE user:1 SET account = 'apple', email = 'test@surrealdb.com';
|
|
|
|
CREATE user:2 SET account = 'tesla', email = 'test@surrealdb.com';
|
|
|
|
CREATE user:3 SET account = 'apple', email = 'test@surrealdb.com';
|
|
|
|
CREATE user:4 SET account = 'tesla', email = 'test@surrealdb.com';
|
2022-09-24 17:58:56 +00:00
|
|
|
DELETE user:1;
|
|
|
|
CREATE user:3 SET account = 'apple', email = 'test@surrealdb.com';
|
|
|
|
CREATE user:4 SET account = 'tesla', email = 'test@surrealdb.com';
|
|
|
|
DELETE user:2;
|
|
|
|
CREATE user:4 SET account = 'tesla', email = 'test@surrealdb.com';
|
2022-07-28 21:40:38 +00:00
|
|
|
";
|
|
|
|
let dbs = Datastore::new("memory").await?;
|
|
|
|
let ses = Session::for_kv().with_ns("test").with_db("test");
|
|
|
|
let res = &mut dbs.execute(&sql, &ses, None, false).await?;
|
2022-09-24 17:58:56 +00:00
|
|
|
assert_eq!(res.len(), 12);
|
2022-07-28 21:40:38 +00:00
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
|
|
|
let val = Value::parse(
|
|
|
|
"{
|
|
|
|
ev: {},
|
|
|
|
fd: {},
|
|
|
|
ft: {},
|
|
|
|
ix: { test: 'DEFINE INDEX test ON user FIELDS account, email UNIQUE' },
|
|
|
|
}",
|
|
|
|
);
|
|
|
|
assert_eq!(tmp, val);
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
|
|
|
let val = Value::parse("[{ id: user:1, account: 'apple', email: 'test@surrealdb.com' }]");
|
|
|
|
assert_eq!(tmp, val);
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
|
|
|
let val = Value::parse("[{ id: user:2, account: 'tesla', email: 'test@surrealdb.com' }]");
|
|
|
|
assert_eq!(tmp, val);
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(matches!(
|
|
|
|
tmp.err(),
|
2022-10-19 14:48:50 +00:00
|
|
|
Some(e) if e.to_string() == r#"Database index `test` already contains ['apple', 'test@surrealdb.com'], with record `user:3`"#
|
2022-07-28 21:40:38 +00:00
|
|
|
));
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(matches!(
|
|
|
|
tmp.err(),
|
2022-10-19 14:48:50 +00:00
|
|
|
Some(e) if e.to_string() == r#"Database index `test` already contains ['tesla', 'test@surrealdb.com'], with record `user:4`"#
|
2022-07-28 21:40:38 +00:00
|
|
|
));
|
|
|
|
//
|
2022-09-24 17:58:56 +00:00
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
|
|
|
let val = Value::parse("[{ id: user:3, account: 'apple', email: 'test@surrealdb.com' }]");
|
|
|
|
assert_eq!(tmp, val);
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(matches!(
|
|
|
|
tmp.err(),
|
2022-10-19 14:48:50 +00:00
|
|
|
Some(e) if e.to_string() == r#"Database index `test` already contains ['tesla', 'test@surrealdb.com'], with record `user:4`"#
|
2022-09-24 17:58:56 +00:00
|
|
|
));
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
|
|
|
let val = Value::parse("[{ id: user:4, account: 'tesla', email: 'test@surrealdb.com' }]");
|
|
|
|
assert_eq!(tmp, val);
|
|
|
|
//
|
2022-07-28 21:40:38 +00:00
|
|
|
Ok(())
|
|
|
|
}
|
2022-08-25 13:49:33 +00:00
|
|
|
|
|
|
|
#[tokio::test]
|
|
|
|
async fn define_statement_index_single_unique_existing() -> Result<(), Error> {
|
|
|
|
let sql = "
|
|
|
|
CREATE user:1 SET email = 'info@surrealdb.com';
|
|
|
|
CREATE user:2 SET email = 'test@surrealdb.com';
|
|
|
|
CREATE user:3 SET email = 'test@surrealdb.com';
|
|
|
|
DEFINE INDEX test ON user FIELDS email UNIQUE;
|
|
|
|
DEFINE INDEX test ON user COLUMNS email UNIQUE;
|
|
|
|
INFO FOR TABLE user;
|
|
|
|
";
|
|
|
|
let dbs = Datastore::new("memory").await?;
|
|
|
|
let ses = Session::for_kv().with_ns("test").with_db("test");
|
|
|
|
let res = &mut dbs.execute(&sql, &ses, None, false).await?;
|
|
|
|
assert_eq!(res.len(), 6);
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(matches!(
|
|
|
|
tmp.err(),
|
2022-10-19 14:48:50 +00:00
|
|
|
Some(e) if e.to_string() == r#"Database index `test` already contains 'test@surrealdb.com', with record `user:3`"#
|
2022-08-25 13:49:33 +00:00
|
|
|
));
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(matches!(
|
|
|
|
tmp.err(),
|
2022-10-19 14:48:50 +00:00
|
|
|
Some(e) if e.to_string() == r#"Database index `test` already contains 'test@surrealdb.com', with record `user:3`"#
|
2022-08-25 13:49:33 +00:00
|
|
|
));
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
|
|
|
let val = Value::parse(
|
|
|
|
"{
|
|
|
|
ev: {},
|
|
|
|
fd: {},
|
|
|
|
ft: {},
|
|
|
|
ix: {},
|
|
|
|
}",
|
|
|
|
);
|
|
|
|
assert_eq!(tmp, val);
|
|
|
|
//
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[tokio::test]
|
|
|
|
async fn define_statement_index_multiple_unique_existing() -> Result<(), Error> {
|
|
|
|
let sql = "
|
|
|
|
CREATE user:1 SET account = 'apple', email = 'test@surrealdb.com';
|
|
|
|
CREATE user:2 SET account = 'tesla', email = 'test@surrealdb.com';
|
|
|
|
CREATE user:3 SET account = 'apple', email = 'test@surrealdb.com';
|
|
|
|
CREATE user:4 SET account = 'tesla', email = 'test@surrealdb.com';
|
|
|
|
DEFINE INDEX test ON user FIELDS account, email UNIQUE;
|
|
|
|
DEFINE INDEX test ON user COLUMNS account, email UNIQUE;
|
|
|
|
INFO FOR TABLE user;
|
|
|
|
";
|
|
|
|
let dbs = Datastore::new("memory").await?;
|
|
|
|
let ses = Session::for_kv().with_ns("test").with_db("test");
|
|
|
|
let res = &mut dbs.execute(&sql, &ses, None, false).await?;
|
|
|
|
assert_eq!(res.len(), 7);
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(tmp.is_ok());
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(matches!(
|
|
|
|
tmp.err(),
|
2022-10-19 14:48:50 +00:00
|
|
|
Some(e) if e.to_string() == r#"Database index `test` already contains ['apple', 'test@surrealdb.com'], with record `user:3`"#
|
2022-08-25 13:49:33 +00:00
|
|
|
));
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result;
|
|
|
|
assert!(matches!(
|
|
|
|
tmp.err(),
|
2022-10-19 14:48:50 +00:00
|
|
|
Some(e) if e.to_string() == r#"Database index `test` already contains ['apple', 'test@surrealdb.com'], with record `user:3`"#
|
2022-08-25 13:49:33 +00:00
|
|
|
));
|
|
|
|
//
|
|
|
|
let tmp = res.remove(0).result?;
|
|
|
|
let val = Value::parse(
|
|
|
|
"{
|
|
|
|
ev: {},
|
|
|
|
fd: {},
|
|
|
|
ft: {},
|
|
|
|
ix: {},
|
|
|
|
}",
|
|
|
|
);
|
|
|
|
assert_eq!(tmp, val);
|
|
|
|
//
|
|
|
|
Ok(())
|
|
|
|
}
|