View Issue Details

IDProjectCategoryView StatusLast Update
0033372mantisbtdb mssqlpublic2024-02-20 16:58
Reporterroman.brandersky Assigned Todregad  
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
Product Version2.26.0 
Target Version2.26.1Fixed in Version2.26.1 
Summary0033372: SQL error opening Manage Users page with MSSQL
Description

Problem with:
When I click - settings/users, i get this:
APPLICATION ERROR 401

Požiadavka do databázy zlyhala. Chyba databázy #8155: SQLState: 42000
Error Code: 8155
Message: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]No column name was specified for column 2 of 'tmp'.
pri požiadavke: SELECT lower(email) email, id, username
FROM mantis_user_table
WHERE lower(email) IN (
SELECT email
FROM (
SELECT lower(email) email, COUNT(*)
FROM mantis_user_table
GROUP BY lower(email) HAVING COUNT(*) > 1
) tmp
)
TagsNo tags attached.

Activities

roman.brandersky

roman.brandersky

2023-12-01 09:58

reporter   ~0068362

This is the query:
SELECT lower(email) email, id, username
FROM mantis_user_table
WHERE lower(email) IN (
SELECT email
FROM (
SELECT lower(email) email, COUNT()
FROM mantis_user_table
GROUP BY lower(email) HAVING COUNT(
) > 1
) tmp
)
ORDER BY lower(email), username

dregad

dregad

2023-12-01 10:40

developer   ~0068363

The purpose of this query is to identify users with duplicate email addresses. I have tested it with MySQL and PostgreSQL, but unfortunately I do not have access to an SQL server instance so I couldn't confirm for that platform.

I guess that adding AS mycount after SELECT lower(email) email, COUNT(*) should do the trick. You can test this by running the query directly against your database, or in context by editing user_api.php at line 334.

Please confirm if that solves the problem, and if not maybe you can help by providing a query that works on MSSQL.

roman.brandersky

roman.brandersky

2023-12-01 11:24

reporter   ~0068364

Perfect !
thank you so much

dregad

dregad

2023-12-01 18:25

developer   ~0068369

PR https://github.com/mantisbt/mantisbt/pull/1947

Related Changesets

MantisBT: master d18f08fd

2023-12-01 18:03

dregad


Details Diff
Fix SQL error opening Manage Users page with MSSQL

[Microsoft][ODBC Driver 17 for SQL Server][SQL Server]No column name was
specified for column 2 of 'tmp'.

Adding aliases to subquery's columns.

Fixes 0033372
Affected Issues
0033372
mod - core/user_api.php Diff File