Accept Thing as argument to type::thing SQL function
This commit is contained in:
parent
bc16645d38
commit
0c86061086
2 changed files with 20 additions and 11 deletions
|
@ -158,7 +158,7 @@ pub async fn run(ctx: &Context<'_>, name: &str, args: Vec<Value>) -> Result<Valu
|
|||
"type::regex" => args::check(ctx, name, args, Args::One, r#type::regex),
|
||||
"type::string" => args::check(ctx, name, args, Args::One, r#type::string),
|
||||
"type::table" => args::check(ctx, name, args, Args::One, r#type::table),
|
||||
"type::thing" => args::check(ctx, name, args, Args::Two, r#type::thing),
|
||||
"type::thing" => args::check(ctx, name, args, Args::OneTwo, r#type::thing),
|
||||
//
|
||||
_ => unreachable!(),
|
||||
}
|
||||
|
|
|
@ -97,15 +97,24 @@ pub fn table(_: &Context, mut args: Vec<Value>) -> Result<Value, Error> {
|
|||
}
|
||||
|
||||
pub fn thing(_: &Context, mut args: Vec<Value>) -> Result<Value, Error> {
|
||||
let tb = args.remove(0);
|
||||
match args.remove(0) {
|
||||
Value::Thing(id) => Ok(Value::Thing(Thing {
|
||||
tb: tb.as_string(),
|
||||
id: id.id,
|
||||
})),
|
||||
id => Ok(Value::Thing(Thing {
|
||||
tb: tb.as_string(),
|
||||
id: id.as_string().into(),
|
||||
})),
|
||||
match args.len() {
|
||||
2 => {
|
||||
let tb = args.remove(0);
|
||||
match args.remove(0) {
|
||||
Value::Thing(id) => Ok(Value::Thing(Thing {
|
||||
tb: tb.as_string(),
|
||||
id: id.id,
|
||||
})),
|
||||
id => Ok(Value::Thing(Thing {
|
||||
tb: tb.as_string(),
|
||||
id: id.as_string().into(),
|
||||
})),
|
||||
}
|
||||
}
|
||||
1 => match args.remove(0) {
|
||||
Value::Thing(v) => Ok(v.into()),
|
||||
_ => Ok(Value::None),
|
||||
},
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue