diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2023-12-31 13:00:35 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-31 05:00:35 +0000 |
commit | da58bb85fa4ff8a37f843d09452b4244b18f93ce (patch) | |
tree | b1b79552332abc25d1fd65ea65ded1f4de3babdf /models | |
parent | f8a1bad883aa4697b4001f74e2074898d7162aef (diff) | |
download | gitea-da58bb85fa4ff8a37f843d09452b4244b18f93ce.tar.gz gitea-da58bb85fa4ff8a37f843d09452b4244b18f93ce.zip |
Upgrade xorm to new version which supported update join for all supported databases (#28590)
Fix https://github.com/go-gitea/gitea/pull/28547#issuecomment-1867740842
Since https://gitea.com/xorm/xorm/pulls/2383 merged, xorm now supports
UPDATE JOIN.
To keep consistent from different databases, xorm use
`engine.Join().Update`, but the actural generated SQL are different
between different databases.
For MySQL, it's `UPDATE talbe1 JOIN table2 ON join_conditions SET xxx
Where xxx`.
For MSSQL, it's `UPDATE table1 SET xxx FROM TABLE1, TABLE2 WHERE
join_conditions`.
For SQLITE per https://www.sqlite.org/lang_update.html, sqlite support
`UPDATE table1 SET xxx FROM table2 WHERE join conditions` from
3.33.0(2020-8-14).
POSTGRES is the same as SQLITE.
Diffstat (limited to 'models')
-rw-r--r-- | models/issues/comment.go | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/models/issues/comment.go b/models/issues/comment.go index d92e49a444..7b068d4983 100644 --- a/models/issues/comment.go +++ b/models/issues/comment.go @@ -1161,14 +1161,9 @@ func DeleteComment(ctx context.Context, comment *Comment) error { // UpdateCommentsMigrationsByType updates comments' migrations information via given git service type and original id and poster id func UpdateCommentsMigrationsByType(ctx context.Context, tp structs.GitServiceType, originalAuthorID string, posterID int64) error { _, err := db.GetEngine(ctx).Table("comment"). - Where(builder.In("issue_id", - builder.Select("issue.id"). - From("issue"). - InnerJoin("repository", "issue.repo_id = repository.id"). - Where(builder.Eq{ - "repository.original_service_type": tp, - }), - )). + Join("INNER", "issue", "issue.id = comment.issue_id"). + Join("INNER", "repository", "issue.repo_id = repository.id"). + Where("repository.original_service_type = ?", tp). And("comment.original_author_id = ?", originalAuthorID). Update(map[string]any{ "poster_id": posterID, |