summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2023-09-23 14:57:39 +0200
committerGitHub <noreply@github.com>2023-09-23 14:57:39 +0200
commitbcb78e70ca81293a705b467e9ce2b77ab04a799e (patch)
tree6bce3e9f68b9d6deab2aa00ad40895e5d2f28cb9 /models
parentFix push mirror, wrong timestamp format (#27153) (diff)
downloadforgejo-bcb78e70ca81293a705b467e9ce2b77ab04a799e.tar.xz
forgejo-bcb78e70ca81293a705b467e9ce2b77ab04a799e.zip
Quote table `release` in sql queries (#27205)
Fixes #27174 `release` is a reserved keyword in MySql. I can't reproduce the issue on my setup and we have a test for that code but it seems there can be setups where it fails. https://github.com/go-gitea/gitea/blob/a101dbaa7952e359843c6d8303ca24a0e63c865c/tests/integration/repo_activity_test.go#L45-L46
Diffstat (limited to 'models')
-rw-r--r--models/activities/repo_activity.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/models/activities/repo_activity.go b/models/activities/repo_activity.go
index 509f9caaf3..91f5ac12bd 100644
--- a/models/activities/repo_activity.go
+++ b/models/activities/repo_activity.go
@@ -342,7 +342,7 @@ func (stats *ActivityStats) FillReleases(ctx context.Context, repoID int64, from
// Published releases list
sess := releasesForActivityStatement(ctx, repoID, fromTime)
- sess.OrderBy("release.created_unix DESC")
+ sess.OrderBy("`release`.created_unix DESC")
stats.PublishedReleases = make([]*repo_model.Release, 0)
if err = sess.Find(&stats.PublishedReleases); err != nil {
return err
@@ -350,7 +350,7 @@ func (stats *ActivityStats) FillReleases(ctx context.Context, repoID int64, from
// Published releases authors
sess = releasesForActivityStatement(ctx, repoID, fromTime)
- if _, err = sess.Select("count(distinct release.publisher_id) as `count`").Table("release").Get(&count); err != nil {
+ if _, err = sess.Select("count(distinct `release`.publisher_id) as `count`").Table("release").Get(&count); err != nil {
return err
}
stats.PublishedReleaseAuthorCount = count
@@ -359,7 +359,7 @@ func (stats *ActivityStats) FillReleases(ctx context.Context, repoID int64, from
}
func releasesForActivityStatement(ctx context.Context, repoID int64, fromTime time.Time) *xorm.Session {
- return db.GetEngine(ctx).Where("release.repo_id = ?", repoID).
- And("release.is_draft = ?", false).
- And("release.created_unix >= ?", fromTime.Unix())
+ return db.GetEngine(ctx).Where("`release`.repo_id = ?", repoID).
+ And("`release`.is_draft = ?", false).
+ And("`release`.created_unix >= ?", fromTime.Unix())
}