一旦我尝试用数字变量替换表名,代码就会中断。我在 $1 处出现语法错误。
我应该逃避它吗?
如果问题是数字参数,我可以尝试其他方法。
let players = sqlx::query_as!(
DatabaseGym,
"select * from ( select * FROM $1 where player=$2 and time <= $3 ORDER BY time desc limit $4 ) temp ORDER BY time asc;",
matched_table.to_owned(),
player.to_owned(),
&x.time,
count
).fetch_all(&self.pg_pool)
.await.unwrap();