rappasoft / laravel-authentication-log

Log user authentication details and send new device notifications.
MIT License
783 stars 95 forks source link

A column has been specified more than once in the order by list. Columns in the order by list must be unique. #111

Open rebecajuliaa9 opened 1 month ago

rebecajuliaa9 commented 1 month ago

Discussed in https://github.com/rappasoft/laravel-authentication-log/discussions/110

Originally posted by **rebecajuliaa9** September 23, 2024 Here's the translation of the requested text into English: The trait AuthenticationLoggable, in the authentications method, returns the user's login information, ordered by login_at. However, in the LogoutListener class, when fetching the most recent login log for the user, an additional ORDER BY clause is applied. Since the ordering is already defined in the trait, applying another ORDER BY results in an error due to the duplication of the clause. This issue is specific to SQL Server, which requires that columns in the ORDER BY list be unique. When the same column is specified more than once, SQL Server throws the following error: "A column has been specified more than once in the order by list. Columns in the order by list must be unique." To resolve this, it’s important to ensure the ordering is applied only once—either in the trait or in the LogoutListener class—avoiding the duplication that leads to this error. Trait AuthenticationLoggable ![image](https://github.com/user-attachments/assets/3bab1294-ff22-43a3-b5a0-5956a5a81654) Listener Logout ![image](https://github.com/user-attachments/assets/eb9713f5-8acd-4076-8ac1-2fb409112658)