Comments (3)
No this requires a change in gogs to process this correctly for mssql.
I did a local recompile with the following changes, if that helps anyone fix this.
file: internal/db/actions.go
func (db *actions) ListByUser(ctx context.Context, userID, actorID, afterID int64, isProfile bool) ([]*Action, error) {
diff --git a/internal/db/repo.go b/internal/db/repo.go
index 8f15ea2b..fff66768 100644
--- a/internal/db/repo.go
+++ b/internal/db/repo.go
@@ -2392,7 +2392,7 @@ func GetWatchers(repoID int64) ([]*Watch, error) {
func (repo *Repository) GetWatchers(page int) ([]*User, error) {
users := make([]*User, 0, ItemsPerPage)
sess := x.Limit(ItemsPerPage, (page-1)*ItemsPerPage).Where("watch.repo_id=?", repo.ID)
- if conf.UsePostgreSQL {
+ if conf.UsePostgreSQL || conf.UseMSSQL {
sess = sess.Join("LEFT", "watch", `"user".id=watch.user_id`)
} else {
sess = sess.Join("LEFT", "watch", "user.id=watch.user_id")
@@ -2492,7 +2492,7 @@ func IsStaring(userID, repoID int64) bool {
func (repo *Repository) GetStargazers(page int) ([]*User, error) {
users := make([]*User, 0, ItemsPerPage)
sess := x.Limit(ItemsPerPage, (page-1)*ItemsPerPage).Where("star.repo_id=?", repo.ID)
- if conf.UsePostgreSQL {
+ if conf.UsePostgreSQL || conf.UseMSSQL {
sess = sess.Join("LEFT", "star", `"user".id=star.uid`)
} else {
sess = sess.Join("LEFT", "star", "user.id=star.uid")
diff --git a/internal/dbutil/string.go b/internal/dbutil/string.go
index 4ee3f012..9afeb2d3 100644
--- a/internal/dbutil/string.go
+++ b/internal/dbutil/string.go
@@ -11,12 +11,16 @@ import (
)
// Quote adds surrounding double quotes for all given arguments before being
-// formatted if the current database is UsePostgreSQL.
+// formatted if the current database is UsePostgreSQL
+// Quote adds surrounding square brackets for all given arguments before being
+// formatted if the current database is UseMSSQL.
func Quote(format string, args ...string) string {
anys := make([]any, len(args))
for i := range args {
if conf.UsePostgreSQL {
anys[i] = `"` + args[i] + `"`
+ } else if conf.UseMSSQL {
+ anys[i] = `[` + args[i] + `]`
} else {
anys[i] = args[i]
}
from gogs.
The term user is a mssql reserved word so in the FROM and WHERE parts of the query the usage of user must be quoted i.e. user.type = '0' should be "user".type or [user].type
from gogs.
Thanks. Is there something I can do about this? The query is generated by Gogs.
from gogs.
Related Issues (20)
- Would you like to take over gogs.info domain?
- gogs restore in Docker failure - GOGS_CUSTOM /data/gogs is moved HOT 2
- backup/restore: User.Passwd renamed to .Password between v0.12 and v0.13 - restore fails to restore passwords HOT 1
- Backing up fails due to a missing file HOT 1
- 加载慢 HOT 10
- Error 1062 (23000): Duplicate entry '' for key 'access_token.sha256' HOT 2
- panic: runtime error: invalid memory address or nil pointer dereference - push commit HOT 4
- how to migrate gogs from sqlite to mariaDB(mysql) ?
- Add riscv64 support
- Database changes in 0.12.11? HOT 1
- Docker gogs started with an error message HOT 3
- Docker gogs cannot be restarted HOT 2
- mention user popover helper
- SSL Certificate error on https://try.gogs.io/ HOT 1
- Use user request 'Host' replace `conf.Server.ExternalURL` in `internal/route/lfs /batch.go`
- Release [VERSION] HOT 1
- klish
- gogs demo site SSL config is wrong and can't be bypassed
- gogs restore report: The system cannot move the file to a different disk drive. It's caused by 'rename' file to a different disk drive on Windows Server 2019.
- Error upgrading 0.12.* to 0.13
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gogs.