向 SurrealDB 发送"创建"RPC 消息会返回"There was a problem with the database: The table does not exist"错误



我正在调试.NET SurralDB库的一些测试。我可以很好地打开到数据库的连接,但当我向数据库(docker容器(发送createRPC消息时,它返回一个错误;数据库出现问题:表不存在";

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
},

这一问题已经得到修复,如果客户端未经授权,现在应该会返回查询权限错误。

相关内容

最新更新