From 66bf74d1b924a91c279d3c68cb01d038300b551a Mon Sep 17 00:00:00 2001
From: Adyanth H <33192449+adyanth@users.noreply.github.com>
Date: Wed, 30 Jun 2021 22:07:20 +0530
Subject: [PATCH] Escape reference to `user` table in models.SearchEmails
 (#16313)

Fix #16312

Signed-off-by: Adyanth H <adyanthh@gmail.com>
---
 models/user_mail.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/models/user_mail.go b/models/user_mail.go
index 2758dfb8e8..320f2cb05a 100644
--- a/models/user_mail.go
+++ b/models/user_mail.go
@@ -316,7 +316,7 @@ type SearchEmailResult struct {
 // SearchEmails takes options i.e. keyword and part of email name to search,
 // it returns results in given range and number of total results.
 func SearchEmails(opts *SearchEmailOptions) ([]*SearchEmailResult, int64, error) {
-	var cond builder.Cond = builder.Eq{"user.`type`": UserTypeIndividual}
+	var cond builder.Cond = builder.Eq{"`user`.`type`": UserTypeIndividual}
 	if len(opts.Keyword) > 0 {
 		likeStr := "%" + strings.ToLower(opts.Keyword) + "%"
 		cond = cond.And(builder.Or(