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

FirstOrCreate(gorm@v1.23.4) return RowsAffected with value 1 when record already exist #5249

Closed
gaosmoon opened this issue Apr 13, 2022 · 2 comments · Fixed by #5250
Closed
Assignees
Labels

Comments

@gaosmoon
Copy link

FirstOrCreate RowsAffected

Description

#4996 has fix, but gorm@v1.23.4 still exists.

demo

        user := User{
		Id:      id,
		CreateTime:   timeNow,
	}

	result := db.FirstOrCreate(&user, &User{
			Id:  id,
	})
        if db.Error != nil {
		return db.Error
	}

	logrus.Debugf("find or create user RowsAffected = %d, result = %v", result.RowsAffected, result)

log

find or create user RowsAffected = 1, result = &{0xc0005c4ea0 <nil> 1 0xc00d018c40 0}
@github-actions github-actions bot added the type:missing reproduction steps missing reproduction steps label Apr 13, 2022
@github-actions
Copy link

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.ioSearch Before Asking

@AzraelJi
Copy link

https://github.com/go-gorm/gorm/pull/5250,fix: FirstOrCreate RowsAffected,请问这个bug在哪个版本已经被merge修复了?查看了v1.24.6仍然未修复

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants