我正在为.NET SurrealDB库调试一些测试。我可以很好地打开到数据库的连接,但是当我向db (docker容器)发送create RPC消息时,它会返回一个错误,即“数据库有问题:表不存在”。
TRACE tungstenite::protocol Received message {"id":"02B70C1AFE5D","async":true,"method":"create","params":["users",{"username":"john","password":"test123"}]}
...
16 13:46:45] DEBUG surrealdb::dbs Executing: CREATE $what CONTENT $data RETURN AFTER
surreal_1 | [2022-09-16 13:46:45] TRACE surrealdb::dbs Iterating: CREATE $what CONTENT $data RETURN AFTERcode: -32000, message: "There was a problem with the database: The table does not exist"
知道为什么会这样吗?当然,这个表不存在,因为我正在尝试创建它。在超现实代码中,还会有另一个原因返回这样的错误吗?
发布于 2022-09-16 20:43:46
错误信息是一条红鲱鱼。实际问题是,客户端有一个错误,不允许它正确登录,因此它没有被授权对数据库进行更改。
违规代码:
// The table doesn't exist
Err(Error::TbNotFound) => match opt.auth.check(Level::Db) {
// We can create the table automatically
true => {
run.add_and_cache_ns(opt.ns(), opt.strict).await?;
run.add_and_cache_db(opt.ns(), opt.db(), opt.strict).await?;
run.add_and_cache_tb(opt.ns(), opt.db(), &rid.tb, opt.strict).await
}
// We can't create the table so error
false => Err(Error::TbNotFound), // Wrong Error Message
},这已经修复,如果客户端是未经授权的,现在应该返回查询权限错误。
https://stackoverflow.com/questions/73747153
复制相似问题