我正在调试 .NET SurrealDB 库的一些测试。我可以很好地打开与数据库的连接,但是当我发送create
向数据库(docker 容器)发送 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 AFTER
code: -32000, message: "There was a problem with the database: The table does not exist"
知道为什么会发生这种情况吗?当然,该表不存在,因为我正在尝试创建它。 Surreal代码中是否还有其他原因会返回这样的错误?
该错误消息是一个转移注意力的信息。实际问题是客户端出现错误,导致其无法正确登录,因此无权对数据库进行更改。
违规代码:
// 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
},
此问题已得到修复,如果客户端未经授权,现在应该返回查询权限错误。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)