Skip to content

mssql: Error 500 on /watchers & /stars #5482

Closed

Description

@22222
  • Gogs version (or commit ref): 0.11.66
  • Git version: 2.19.1
  • Operating system: Windows
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gogs.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist (usually found in log/gogs.log):

2018/10/16 07:14:21 [ERROR] [.../routes/repo/view.go:331 RenderUserCards()] getter: mssql: Cannot call methods on nvarchar.

Description

This is the same issue as #2176, but with mssql instead of postgresql.

The watchers page runs a query like this with mssql:

SELECT  TOP 40 * FROM "user" LEFT JOIN "watch" ON user.id=watch.user_id WHERE watch.repo_id=1

That results in this error:

Cannot call methods on nvarchar.

The fix in commit 9178993 added double quotes to escape the "user" alias just when setting.UsePostgreSQL is true. That same fix should work here if it's updated to use that quoted version when setting.UseMSSQL is true.

Activity

  1. added this to the milestone on Oct 30, 2018
  2. laojianzi commented on Oct 14, 2020

    @laojianzi
    Contributor

    @22222 Thank

    I tried, you're right.

    The fix in commit 9178993 added double quotes to escape the "user" alias just when setting.UsePostgreSQL is true. That same fix should work here if it's updated to use that quoted version when setting.UseMSSQL is true.

  3. removed this from the milestone on Mar 5, 2022
  4. added a commit that references this issue on Jan 31, 2026
    f7c8750
  5. locked as resolved and limited conversation to collaborators on May 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      ⌂ 换网址