Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

查找用户的 dbCounter 党 loginPolicyId 为空时 会导致dbCounter 重新定义 #329

Closed
vivi-ui opened this issue Jan 13, 2023 · 0 comments

Comments

@vivi-ui
Copy link

vivi-ui commented Jan 13, 2023

func (r userRepository) Find(c context.Context, pageIndex, pageSize int, username, nickname, mail, online, loginPolicyId, order, field string) (o []model.UserForPage, total int64, err error) {
db := r.GetDB(c).Table("users").Select("users.id,users.username,users.nickname,users.mail,users.online,users.created,users.type,users.status,users.source, users.totp_secret")
dbCounter := r.GetDB(c).Table("users")

if loginPolicyId != "" {
	db = db.Joins("left join login_policies_ref as ref on users.id = ref.user_id")
	dbCounter = dbCounter.Joins("left join login_policies_ref as ref on users.id = ref.user_id")

	db = db.Where("ref.login_policy_id = ?", loginPolicyId)

下面使用db.Where 那上面定义的dbCounter 就无效了
dbCounter = db.Where("ref.login_policy_id = ?", loginPolicyId)
}

dushixiang pushed a commit that referenced this issue Feb 5, 2024
- 修复导入备份时资产所有者未替换的问题
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant