.generate()
should not format table name (#4102)
This commit is contained in:
parent
5df3d2d190
commit
e98a56958b
2 changed files with 11 additions and 11 deletions
|
@ -9,44 +9,44 @@ impl Value {
|
||||||
match self {
|
match self {
|
||||||
// There is a floating point number for the id field
|
// There is a floating point number for the id field
|
||||||
Value::Number(id) if id.is_float() => Ok(Thing {
|
Value::Number(id) if id.is_float() => Ok(Thing {
|
||||||
tb: tb.to_string(),
|
tb: tb.0.to_string(),
|
||||||
id: id.as_int().into(),
|
id: id.as_int().into(),
|
||||||
}),
|
}),
|
||||||
// There is an integer number for the id field
|
// There is an integer number for the id field
|
||||||
Value::Number(id) if id.is_int() => Ok(Thing {
|
Value::Number(id) if id.is_int() => Ok(Thing {
|
||||||
tb: tb.to_string(),
|
tb: tb.0.to_string(),
|
||||||
id: id.as_int().into(),
|
id: id.as_int().into(),
|
||||||
}),
|
}),
|
||||||
// There is a string for the id field
|
// There is a string for the id field
|
||||||
Value::Strand(id) if !id.is_empty() => Ok(Thing {
|
Value::Strand(id) if !id.is_empty() => Ok(Thing {
|
||||||
tb: tb.to_string(),
|
tb: tb.0.to_string(),
|
||||||
id: id.into(),
|
id: id.into(),
|
||||||
}),
|
}),
|
||||||
// There is an object for the id field
|
// There is an object for the id field
|
||||||
Value::Object(id) => Ok(Thing {
|
Value::Object(id) => Ok(Thing {
|
||||||
tb: tb.to_string(),
|
tb: tb.0.to_string(),
|
||||||
id: id.into(),
|
id: id.into(),
|
||||||
}),
|
}),
|
||||||
// There is an array for the id field
|
// There is an array for the id field
|
||||||
Value::Array(id) => Ok(Thing {
|
Value::Array(id) => Ok(Thing {
|
||||||
tb: tb.to_string(),
|
tb: tb.0.to_string(),
|
||||||
id: id.into(),
|
id: id.into(),
|
||||||
}),
|
}),
|
||||||
// There is a UUID for the id field
|
// There is a UUID for the id field
|
||||||
Value::Uuid(id) => Ok(Thing {
|
Value::Uuid(id) => Ok(Thing {
|
||||||
tb: tb.to_string(),
|
tb: tb.0.to_string(),
|
||||||
id: id.into(),
|
id: id.into(),
|
||||||
}),
|
}),
|
||||||
// There is no record id field
|
// There is no record id field
|
||||||
Value::None => Ok(Thing {
|
Value::None => Ok(Thing {
|
||||||
tb: tb.to_string(),
|
tb: tb.0.to_string(),
|
||||||
id: Id::rand(),
|
id: Id::rand(),
|
||||||
}),
|
}),
|
||||||
// There is a record id defined
|
// There is a record id defined
|
||||||
Value::Thing(id) => match retable {
|
Value::Thing(id) => match retable {
|
||||||
// Let's re-table this record id
|
// Let's re-table this record id
|
||||||
true => Ok(Thing {
|
true => Ok(Thing {
|
||||||
tb: tb.to_string(),
|
tb: tb.0.to_string(),
|
||||||
id: id.id,
|
id: id.id,
|
||||||
}),
|
}),
|
||||||
// Let's use the specified record id
|
// Let's use the specified record id
|
||||||
|
@ -55,7 +55,7 @@ impl Value {
|
||||||
true => Ok(id),
|
true => Ok(id),
|
||||||
// The record id is from another table
|
// The record id is from another table
|
||||||
false => Ok(Thing {
|
false => Ok(Thing {
|
||||||
tb: tb.to_string(),
|
tb: tb.0.to_string(),
|
||||||
id: id.id,
|
id: id.id,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
|
|
@ -11,7 +11,7 @@ use surrealdb::sql::Value;
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn insert_statement_object_single() -> Result<(), Error> {
|
async fn insert_statement_object_single() -> Result<(), Error> {
|
||||||
let sql = "
|
let sql = "
|
||||||
INSERT INTO test {
|
INSERT INTO `test-table` {
|
||||||
id: 'tester',
|
id: 'tester',
|
||||||
test: true,
|
test: true,
|
||||||
something: 'other',
|
something: 'other',
|
||||||
|
@ -23,7 +23,7 @@ async fn insert_statement_object_single() -> Result<(), Error> {
|
||||||
assert_eq!(res.len(), 1);
|
assert_eq!(res.len(), 1);
|
||||||
//
|
//
|
||||||
let tmp = res.remove(0).result?;
|
let tmp = res.remove(0).result?;
|
||||||
let val = Value::parse("[{ id: test:tester, test: true, something: 'other' }]");
|
let val = Value::parse("[{ id: `test-table`:tester, test: true, something: 'other' }]");
|
||||||
assert_eq!(tmp, val);
|
assert_eq!(tmp, val);
|
||||||
//
|
//
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Reference in a new issue