[Bug]: accounts -> recently active does not work on pgsql #46777
Closed
Description
⚠️ This issue respects the following points: ⚠️
- This is a bug, not a question or a configuration/webserver/proxy issue.
- This issue is not already reported on Github OR Nextcloud Community Forum (I've searched it).
- Nextcloud Server is up to date. See Maintenance and Release Schedule for supported versions.
- I agree to follow Nextcloud's Code of Conduct.
Bug description
{
"reqId": "A6OrF4dDo5d6KbSG0EQI",
"level": 3,
"time": "2024-07-26T10:09:35+00:00",
"remoteAddr": "172.19.0.1",
"user": "admin",
"app": "no app in context",
"method": "GET",
"url": "/ocs/v2.php/cloud/users/recent?offset=0&limit=25&search=",
"message": "An exception occurred while executing a query: SQLSTATE[42P10]: Invalid column reference: 7 ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list\nLINE 1: ...in') AND (\"p\".\"configkey\" = 'lastLogin') ORDER BY LOWER(\"p\"....\n ^",
"userAgent": "Mozilla/5.0 (X11; Linux x86_64; rv:129.0) Gecko/20100101 Firefox/129.0",
"version": "30.0.0.3",
"exception": {
"Exception": "OC\\DB\\Exceptions\\DbalException",
"Message": "An exception occurred while executing a query: SQLSTATE[42P10]: Invalid column reference: 7 ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list\nLINE 1: ...in') AND (\"p\".\"configkey\" = 'lastLogin') ORDER BY LOWER(\"p\"....\n ^",
"Code": 7,
"Trace": [
{
"file": "/var/www/html/lib/private/DB/ConnectionAdapter.php",
"line": 51,
"function": "wrap",
"class": "OC\\DB\\Exceptions\\DbalException",
"type": "::",
"args": [
[
"Doctrine\\DBAL\\Exception\\DriverException"
]
]
},
{
"file": "/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php",
"line": 271,
"function": "executeQuery",
"class": "OC\\DB\\ConnectionAdapter",
"type": "->",
"args": [
"SELECT DISTINCT `uid` FROM `*PREFIX*users` `u` LEFT JOIN `*PREFIX*preferences` `p` ON (`p`.`userid` = `uid`) AND (`p`.`appid` = 'login') AND (`p`.`configkey` = 'lastLogin') ORDER BY LOWER(`p`.`configvalue`) DESC, `uid_lower` ASC LIMIT 25",
[],
[]
]
},
{
"file": "/var/www/html/lib/private/User/Manager.php",
"line": 771,
"function": "executeQuery",
"class": "OC\\DB\\QueryBuilder\\QueryBuilder",
"type": "->",
"args": []
},
{
"file": "/var/www/html/apps/provisioning_api/lib/Controller/UsersController.php",
"line": 305,
"function": "getLastLoggedInUsers",
"class": "OC\\User\\Manager",
"type": "->",
"args": [
25,
0,
""
]
},
{
"file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php",
"line": 208,
"function": "getLastLoggedInUsers",
"class": "OCA\\Provisioning_API\\Controller\\UsersController",
"type": "->",
"args": [
"",
25,
0
]
},
{
"file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php",
"line": 114,
"function": "executeController",
"class": "OC\\AppFramework\\Http\\Dispatcher",
"type": "->",
"args": [
[
"OCA\\Provisioning_API\\Controller\\UsersController"
],
"getLastLoggedInUsers"
]
},
{
"file": "/var/www/html/lib/private/AppFramework/App.php",
"line": 161,
"function": "dispatch",
"class": "OC\\AppFramework\\Http\\Dispatcher",
"type": "->",
"args": [
[
"OCA\\Provisioning_API\\Controller\\UsersController"
],
"getLastLoggedInUsers"
]
},
{
"file": "/var/www/html/lib/private/Route/Router.php",
"line": 309,
"function": "main",
"class": "OC\\AppFramework\\App",
"type": "::",
"args": [
"OCA\\Provisioning_API\\Controller\\UsersController",
"getLastLoggedInUsers",
[
"OC\\AppFramework\\DependencyInjection\\DIContainer"
],
[
"ocs.provisioning_api.users.getlastloggedinusers"
]
]
},
{
"file": "/var/www/html/ocs/v1.php",
"line": 43,
"function": "match",
"class": "OC\\Route\\Router",
"type": "->",
"args": [
"/ocsapp/cloud/users/recent"
]
},
{
"file": "/var/www/html/ocs/v2.php",
"line": 7,
"args": [
"/var/www/html/ocs/v1.php"
],
"function": "require_once"
}
],
"File": "/var/www/html/lib/private/DB/Exceptions/DbalException.php",
"Line": 54,
"Previous": {
"Exception": "Doctrine\\DBAL\\Exception\\DriverException",
"Message": "An exception occurred while executing a query: SQLSTATE[42P10]: Invalid column reference: 7 ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list\nLINE 1: ...in') AND (\"p\".\"configkey\" = 'lastLogin') ORDER BY LOWER(\"p\"....\n ^",
"Code": 7,
"Trace": [
{
"file": "/var/www/html/3rdparty/doctrine/dbal/src/Connection.php",
"line": 1943,
"function": "convert",
"class": "Doctrine\\DBAL\\Driver\\API\\PostgreSQL\\ExceptionConverter",
"type": "->",
"args": [
[
"Doctrine\\DBAL\\Driver\\PDO\\Exception"
],
[
"Doctrine\\DBAL\\Query"
]
]
},
{
"file": "/var/www/html/3rdparty/doctrine/dbal/src/Connection.php",
"line": 1885,
"function": "handleDriverException",
"class": "Doctrine\\DBAL\\Connection",
"type": "->",
"args": [
[
"Doctrine\\DBAL\\Driver\\PDO\\Exception"
],
[
"Doctrine\\DBAL\\Query"
]
]
},
{
"file": "/var/www/html/3rdparty/doctrine/dbal/src/Connection.php",
"line": 1106,
"function": "convertExceptionDuringQuery",
"class": "Doctrine\\DBAL\\Connection",
"type": "->",
"args": [
[
"Doctrine\\DBAL\\Driver\\PDO\\Exception"
],
"SELECT DISTINCT \"uid\" FROM \"oc_users\" \"u\" LEFT JOIN \"oc_preferences\" \"p\" ON (\"p\".\"userid\" = \"uid\") AND (\"p\".\"appid\" = 'login') AND (\"p\".\"configkey\" = 'lastLogin') ORDER BY LOWER(\"p\".\"configvalue\") DESC, \"uid_lower\" ASC LIMIT 25",
[],
[]
]
},
{
"file": "/var/www/html/lib/private/DB/Connection.php",
"line": 312,
"function": "executeQuery",
"class": "Doctrine\\DBAL\\Connection",
"type": "->",
"args": [
"SELECT DISTINCT \"uid\" FROM \"oc_users\" \"u\" LEFT JOIN \"oc_preferences\" \"p\" ON (\"p\".\"userid\" = \"uid\") AND (\"p\".\"appid\" = 'login') AND (\"p\".\"configkey\" = 'lastLogin') ORDER BY LOWER(\"p\".\"configvalue\") DESC, \"uid_lower\" ASC LIMIT 25",
[],
[],
null
]
},
{
"file": "/var/www/html/lib/private/DB/ConnectionAdapter.php",
"line": 48,
"function": "executeQuery",
"class": "OC\\DB\\Connection",
"type": "->",
"args": [
"SELECT DISTINCT \"uid\" FROM \"oc_users\" \"u\" LEFT JOIN \"oc_preferences\" \"p\" ON (\"p\".\"userid\" = \"uid\") AND (\"p\".\"appid\" = 'login') AND (\"p\".\"configkey\" = 'lastLogin') ORDER BY LOWER(\"p\".\"configvalue\") DESC, \"uid_lower\" ASC LIMIT 25",
[],
[]
]
},
{
"file": "/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php",
"line": 271,
"function": "executeQuery",
"class": "OC\\DB\\ConnectionAdapter",
"type": "->",
"args": [
"SELECT DISTINCT `uid` FROM `*PREFIX*users` `u` LEFT JOIN `*PREFIX*preferences` `p` ON (`p`.`userid` = `uid`) AND (`p`.`appid` = 'login') AND (`p`.`configkey` = 'lastLogin') ORDER BY LOWER(`p`.`configvalue`) DESC, `uid_lower` ASC LIMIT 25",
[],
[]
]
},
{
"file": "/var/www/html/lib/private/User/Manager.php",
"line": 771,
"function": "executeQuery",
"class": "OC\\DB\\QueryBuilder\\QueryBuilder",
"type": "->",
"args": []
},
{
"file": "/var/www/html/apps/provisioning_api/lib/Controller/UsersController.php",
"line": 305,
"function": "getLastLoggedInUsers",
"class": "OC\\User\\Manager",
"type": "->",
"args": [
25,
0,
""
]
},
{
"file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php",
"line": 208,
"function": "getLastLoggedInUsers",
"class": "OCA\\Provisioning_API\\Controller\\UsersController",
"type": "->",
"args": [
"",
25,
0
]
},
{
"file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php",
"line": 114,
"function": "executeController",
"class": "OC\\AppFramework\\Http\\Dispatcher",
"type": "->",
"args": [
[
"OCA\\Provisioning_API\\Controller\\UsersController"
],
"getLastLoggedInUsers"
]
},
{
"file": "/var/www/html/lib/private/AppFramework/App.php",
"line": 161,
"function": "dispatch",
"class": "OC\\AppFramework\\Http\\Dispatcher",
"type": "->",
"args": [
[
"OCA\\Provisioning_API\\Controller\\UsersController"
],
"getLastLoggedInUsers"
]
},
{
"file": "/var/www/html/lib/private/Route/Router.php",
"line": 309,
"function": "main",
"class": "OC\\AppFramework\\App",
"type": "::",
"args": [
"OCA\\Provisioning_API\\Controller\\UsersController",
"getLastLoggedInUsers",
[
"OC\\AppFramework\\DependencyInjection\\DIContainer"
],
[
"ocs.provisioning_api.users.getlastloggedinusers"
]
]
},
{
"file": "/var/www/html/ocs/v1.php",
"line": 43,
"function": "match",
"class": "OC\\Route\\Router",
"type": "->",
"args": [
"/ocsapp/cloud/users/recent"
]
},
{
"file": "/var/www/html/ocs/v2.php",
"line": 7,
"args": [
"/var/www/html/ocs/v1.php"
],
"function": "require_once"
}
],
"File": "/var/www/html/3rdparty/doctrine/dbal/src/Driver/API/PostgreSQL/ExceptionConverter.php",
"Line": 87,
"Previous": {
"Exception": "Doctrine\\DBAL\\Driver\\PDO\\Exception",
"Message": "SQLSTATE[42P10]: Invalid column reference: 7 ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list\nLINE 1: ...in') AND (\"p\".\"configkey\" = 'lastLogin') ORDER BY LOWER(\"p\"....\n ^",
"Code": 7,
"Trace": [
{
"file": "/var/www/html/3rdparty/doctrine/dbal/src/Driver/PDO/Connection.php",
"line": 76,
"function": "new",
"class": "Doctrine\\DBAL\\Driver\\PDO\\Exception",
"type": "::",
"args": [
[
"PDOException",
[
"42P10",
7,
"ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list\nLINE 1: ...in') AND (\"p\".\"configkey\" = 'lastLogin') ORDER BY LOWER(\"p\"....\n ^"
]
]
]
},
{
"file": "/var/www/html/3rdparty/doctrine/dbal/src/Connection.php",
"line": 1101,
"function": "query",
"class": "Doctrine\\DBAL\\Driver\\PDO\\Connection",
"type": "->",
"args": [
"SELECT DISTINCT \"uid\" FROM \"oc_users\" \"u\" LEFT JOIN \"oc_preferences\" \"p\" ON (\"p\".\"userid\" = \"uid\") AND (\"p\".\"appid\" = 'login') AND (\"p\".\"configkey\" = 'lastLogin') ORDER BY LOWER(\"p\".\"configvalue\") DESC, \"uid_lower\" ASC LIMIT 25"
]
},
{
"file": "/var/www/html/lib/private/DB/Connection.php",
"line": 312,
"function": "executeQuery",
"class": "Doctrine\\DBAL\\Connection",
"type": "->",
"args": [
"SELECT DISTINCT \"uid\" FROM \"oc_users\" \"u\" LEFT JOIN \"oc_preferences\" \"p\" ON (\"p\".\"userid\" = \"uid\") AND (\"p\".\"appid\" = 'login') AND (\"p\".\"configkey\" = 'lastLogin') ORDER BY LOWER(\"p\".\"configvalue\") DESC, \"uid_lower\" ASC LIMIT 25",
[],
[],
null
]
},
{
"file": "/var/www/html/lib/private/DB/ConnectionAdapter.php",
"line": 48,
"function": "executeQuery",
"class": "OC\\DB\\Connection",
"type": "->",
"args": [
"SELECT DISTINCT \"uid\" FROM \"oc_users\" \"u\" LEFT JOIN \"oc_preferences\" \"p\" ON (\"p\".\"userid\" = \"uid\") AND (\"p\".\"appid\" = 'login') AND (\"p\".\"configkey\" = 'lastLogin') ORDER BY LOWER(\"p\".\"configvalue\") DESC, \"uid_lower\" ASC LIMIT 25",
[],
[]
]
},
{
"file": "/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php",
"line": 271,
"function": "executeQuery",
"class": "OC\\DB\\ConnectionAdapter",
"type": "->",
"args": [
"SELECT DISTINCT `uid` FROM `*PREFIX*users` `u` LEFT JOIN `*PREFIX*preferences` `p` ON (`p`.`userid` = `uid`) AND (`p`.`appid` = 'login') AND (`p`.`configkey` = 'lastLogin') ORDER BY LOWER(`p`.`configvalue`) DESC, `uid_lower` ASC LIMIT 25",
[],
[]
]
},
{
"file": "/var/www/html/lib/private/User/Manager.php",
"line": 771,
"function": "executeQuery",
"class": "OC\\DB\\QueryBuilder\\QueryBuilder",
"type": "->",
"args": []
},
{
"file": "/var/www/html/apps/provisioning_api/lib/Controller/UsersController.php",
"line": 305,
"function": "getLastLoggedInUsers",
"class": "OC\\User\\Manager",
"type": "->",
"args": [
25,
0,
""
]
},
{
"file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php",
"line": 208,
"function": "getLastLoggedInUsers",
"class": "OCA\\Provisioning_API\\Controller\\UsersController",
"type": "->",
"args": [
"",
25,
0
]
},
{
"file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php",
"line": 114,
"function": "executeController",
"class": "OC\\AppFramework\\Http\\Dispatcher",
"type": "->",
"args": [
[
"OCA\\Provisioning_API\\Controller\\UsersController"
],
"getLastLoggedInUsers"
]
},
{
"file": "/var/www/html/lib/private/AppFramework/App.php",
"line": 161,
"function": "dispatch",
"class": "OC\\AppFramework\\Http\\Dispatcher",
"type": "->",
"args": [
[
"OCA\\Provisioning_API\\Controller\\UsersController"
],
"getLastLoggedInUsers"
]
},
{
"file": "/var/www/html/lib/private/Route/Router.php",
"line": 309,
"function": "main",
"class": "OC\\AppFramework\\App",
"type": "::",
"args": [
"OCA\\Provisioning_API\\Controller\\UsersController",
"getLastLoggedInUsers",
[
"OC\\AppFramework\\DependencyInjection\\DIContainer"
],
[
"ocs.provisioning_api.users.getlastloggedinusers"
]
]
},
{
"file": "/var/www/html/ocs/v1.php",
"line": 43,
"function": "match",
"class": "OC\\Route\\Router",
"type": "->",
"args": [
"/ocsapp/cloud/users/recent"
]
},
{
"file": "/var/www/html/ocs/v2.php",
"line": 7,
"args": [
"/var/www/html/ocs/v1.php"
],
"function": "require_once"
}
],
"File": "/var/www/html/3rdparty/doctrine/dbal/src/Driver/PDO/Exception.php",
"Line": 28,
"Previous": {
"Exception": "PDOException",
"Message": "SQLSTATE[42P10]: Invalid column reference: 7 ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list\nLINE 1: ...in') AND (\"p\".\"configkey\" = 'lastLogin') ORDER BY LOWER(\"p\"....\n ^",
"Code": "42P10",
"Trace": [
{
"file": "/var/www/html/3rdparty/doctrine/dbal/src/Driver/PDO/Connection.php",
"line": 71,
"function": "query",
"class": "PDO",
"type": "->",
"args": [
"SELECT DISTINCT \"uid\" FROM \"oc_users\" \"u\" LEFT JOIN \"oc_preferences\" \"p\" ON (\"p\".\"userid\" = \"uid\") AND (\"p\".\"appid\" = 'login') AND (\"p\".\"configkey\" = 'lastLogin') ORDER BY LOWER(\"p\".\"configvalue\") DESC, \"uid_lower\" ASC LIMIT 25"
]
},
{
"file": "/var/www/html/3rdparty/doctrine/dbal/src/Connection.php",
"line": 1101,
"function": "query",
"class": "Doctrine\\DBAL\\Driver\\PDO\\Connection",
"type": "->",
"args": [
"SELECT DISTINCT \"uid\" FROM \"oc_users\" \"u\" LEFT JOIN \"oc_preferences\" \"p\" ON (\"p\".\"userid\" = \"uid\") AND (\"p\".\"appid\" = 'login') AND (\"p\".\"configkey\" = 'lastLogin') ORDER BY LOWER(\"p\".\"configvalue\") DESC, \"uid_lower\" ASC LIMIT 25"
]
},
{
"file": "/var/www/html/lib/private/DB/Connection.php",
"line": 312,
"function": "executeQuery",
"class": "Doctrine\\DBAL\\Connection",
"type": "->",
"args": [
"SELECT DISTINCT \"uid\" FROM \"oc_users\" \"u\" LEFT JOIN \"oc_preferences\" \"p\" ON (\"p\".\"userid\" = \"uid\") AND (\"p\".\"appid\" = 'login') AND (\"p\".\"configkey\" = 'lastLogin') ORDER BY LOWER(\"p\".\"configvalue\") DESC, \"uid_lower\" ASC LIMIT 25",
[],
[],
null
]
},
{
"file": "/var/www/html/lib/private/DB/ConnectionAdapter.php",
"line": 48,
"function": "executeQuery",
"class": "OC\\DB\\Connection",
"type": "->",
"args": [
"SELECT DISTINCT \"uid\" FROM \"oc_users\" \"u\" LEFT JOIN \"oc_preferences\" \"p\" ON (\"p\".\"userid\" = \"uid\") AND (\"p\".\"appid\" = 'login') AND (\"p\".\"configkey\" = 'lastLogin') ORDER BY LOWER(\"p\".\"configvalue\") DESC, \"uid_lower\" ASC LIMIT 25",
[],
[]
]
},
{
"file": "/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php",
"line": 271,
"function": "executeQuery",
"class": "OC\\DB\\ConnectionAdapter",
"type": "->",
"args": [
"SELECT DISTINCT `uid` FROM `*PREFIX*users` `u` LEFT JOIN `*PREFIX*preferences` `p` ON (`p`.`userid` = `uid`) AND (`p`.`appid` = 'login') AND (`p`.`configkey` = 'lastLogin') ORDER BY LOWER(`p`.`configvalue`) DESC, `uid_lower` ASC LIMIT 25",
[],
[]
]
},
{
"file": "/var/www/html/lib/private/User/Manager.php",
"line": 771,
"function": "executeQuery",
"class": "OC\\DB\\QueryBuilder\\QueryBuilder",
"type": "->",
"args": []
},
{
"file": "/var/www/html/apps/provisioning_api/lib/Controller/UsersController.php",
"line": 305,
"function": "getLastLoggedInUsers",
"class": "OC\\User\\Manager",
"type": "->",
"args": [
25,
0,
""
]
},
{
"file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php",
"line": 208,
"function": "getLastLoggedInUsers",
"class": "OCA\\Provisioning_API\\Controller\\UsersController",
"type": "->",
"args": [
"",
25,
0
]
},
{
"file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php",
"line": 114,
"function": "executeController",
"class": "OC\\AppFramework\\Http\\Dispatcher",
"type": "->",
"args": [
[
"OCA\\Provisioning_API\\Controller\\UsersController"
],
"getLastLoggedInUsers"
]
},
{
"file": "/var/www/html/lib/private/AppFramework/App.php",
"line": 161,
"function": "dispatch",
"class": "OC\\AppFramework\\Http\\Dispatcher",
"type": "->",
"args": [
[
"OCA\\Provisioning_API\\Controller\\UsersController"
],
"getLastLoggedInUsers"
]
},
{
"file": "/var/www/html/lib/private/Route/Router.php",
"line": 309,
"function": "main",
"class": "OC\\AppFramework\\App",
"type": "::",
"args": [
"OCA\\Provisioning_API\\Controller\\UsersController",
"getLastLoggedInUsers",
[
"OC\\AppFramework\\DependencyInjection\\DIContainer"
],
[
"ocs.provisioning_api.users.getlastloggedinusers"
]
]
},
{
"file": "/var/www/html/ocs/v1.php",
"line": 43,
"function": "match",
"class": "OC\\Route\\Router",
"type": "->",
"args": [
"/ocsapp/cloud/users/recent"
]
},
{
"file": "/var/www/html/ocs/v2.php",
"line": 7,
"args": [
"/var/www/html/ocs/v1.php"
],
"function": "require_once"
}
],
"File": "/var/www/html/3rdparty/doctrine/dbal/src/Driver/PDO/Connection.php",
"Line": 71
}
}
},
"message": "An exception occurred while executing a query: SQLSTATE[42P10]: Invalid column reference: 7 ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list\nLINE 1: ...in') AND (\"p\".\"configkey\" = 'lastLogin') ORDER BY LOWER(\"p\"....\n ^",
"exception": {},
"CustomMessage": "An exception occurred while executing a query: SQLSTATE[42P10]: Invalid column reference: 7 ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list\nLINE 1: ...in') AND (\"p\".\"configkey\" = 'lastLogin') ORDER BY LOWER(\"p\"....\n ^"
}
}
Steps to reproduce
- Use PostgreSQL
- Login as admin
- Visit accounts
- Click "recently active"
- 💥
Expected behavior
No error
Activity