Skip to content
New issue

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

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

Already on GitHub? # to your account

updated_at not touched when generating a query via property obtained from Query in transaction when using gorm.io/gen #785

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mika-f
Copy link

@mika-f mika-f commented Jan 24, 2025

Explain your user case and expected results

Using gorm.io/gen@v0.3.26, gorm.io/gorm@v1.25.12, updated_at not touched in generated query when build via property obtained from Query in transaction:

// expected behavior
query.WriteDB().Transaction(func(tx *q.Query) error {
	user := tx.User
        // UPDATE `users` SET `name`=?,`updated_at`=? WHERE `users`.`name` = ? AND `users`.`deleted_at` IS NULL
	user.WithContext(ctx).Where(user.Name.Eq(name)).UpdateSimple(user.Name.Value("test2"))
	return nil
})

// actual behavior
query.WriteDB().Transaction(func(tx *q.Query) error {
	user := tx.User
	// UPDATE `users` SET `name`=? WHERE `users`.`name` = ? AND `users`.`deleted_at` IS NULL
	user.WithContext(ctx).Where(user.Name.Eq(name)).UpdateSimple(user.Name.Value("test2"))
	return nil
})

…ia property obtained from *q.Query in transaction
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant