为什么我可以使用'@@' prisma mysql全文搜索中的符号?
我已经与Prisma客户端一起编写了一个简单的文本搜索查询,以在我的用户表中搜索用户名或电子邮件。虽然它正确地与用户名一起使用,但错误地说,意外' @'
。我相信这是 @是一个特殊的符号。电子邮件地址。 (电子邮件正确保存在数据库中)。如果我从 @.ex省略零件,请结果结果结果:in ,查询返回匹配匹配如果我只是搜索abc..tut,如果我使用  part  protect ] ,由于此错误而失败。
Error occurred during query execution:
ConnectorError(
ConnectorError {
user_facing_error: None,
kind: QueryError(Server(ServerError {
code: 1064, message: "syntax error,
unexpected '@',expecting $end", state: "42000" }
)) })
我如何解决这个问题,我搜索了文档,但是找不到与此相关的任何内容。 我的用户模型看起来像
model User {
id Int @id @default(autoincrement())
username String @db.VarChar(255)
email String @db.VarChar(255)
avatar String? @db.VarChar(255)
password String @default("1") @db.VarChar(255)
friends User[] @relation("friends")
friendsRelation User[] @relation("friends")
hashRT String? @db.VarChar(255)
@@fulltext([username])
@@fulltext([email])
@@fulltext([username, email])
@@map("users")
}
I've written a simple text search query with the Prisma client to search Usernames or emails in my users table. While it correctly works with usernames, it errors out saying, Unexpected '@'
.I believe that's due to @ is a special symbol.Is there anyway around this, because I need to be able to search full email addresses. (Emails are correctly saved in the database). And query return results if I omit the part from @.Ex: in [email protected], query returns match if I just search abc.But If I use [email protected], it fails with this error.
Error occurred during query execution:
ConnectorError(
ConnectorError {
user_facing_error: None,
kind: QueryError(Server(ServerError {
code: 1064, message: "syntax error,
unexpected '@',expecting $end", state: "42000" }
)) })
How do I solve this, I searched the documentation, but I couldn't find anything related to this.
My User model looks like this,
model User {
id Int @id @default(autoincrement())
username String @db.VarChar(255)
email String @db.VarChar(255)
avatar String? @db.VarChar(255)
password String @default("1") @db.VarChar(255)
friends User[] @relation("friends")
friendsRelation User[] @relation("friends")
hashRT String? @db.VarChar(255)
@@fulltext([username])
@@fulltext([email])
@@fulltext([username, email])
@@map("users")
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个较晚的答案,但是如果您仍然遇到相同的错误,这可能会帮助我通过用这样的包含替换搜索来解决此错误
this is a late answer but if you still had the same error this might help I fixed this error by replacing search with contains like this