-
Notifications
You must be signed in to change notification settings - Fork 767
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Recalculate Conversation.CountParticipants results in invalid SQL due to ambigious subquery. #11128
Comments
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
stale
bot
added
the
Status: Stale
For stale issues that will be automatically closed.
label
Nov 12, 2022
I built 2023.001 this morning from source and this seems to be fixed in this release. Have uploaded the release here if you'd like to download (it works out-of-the-box on PHP 8.1.12 + PHP 8.2.1 without any workarounds!) |
stale
bot
removed
the
Status: Stale
For stale issues that will be automatically closed.
label
Jan 19, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select count(uc.ConversationID) from GDN_UserConversation uc where uc.Conversati' at line 2"
Recalculate Conversation.CountParticipants result in invalid SQL
CountParticipants option is using a sub query which refers to c.CountParticipants but c is not defined in that select statement.
vanilla/applications/conversations/models/class.conversationmodel.php
Lines 80 to 88 in cb6f17d
results is a query like so
update GDN_Conversation set c.CountParticipants=(select count(uc.ConversationID) from GDN_UserConversation uc where uc.ConversationID = c.ConversationID and uc.Deleted = 0);
this would result in the following error if run manually
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select count(uc.ConversationID) from GDN_UserConversation uc where uc.ConversationID = c.ConversationID and uc' at line 1
While you could argue the update statement defines c. c needs to be defined in the subquery to be understood. MySQL Update even supports joins or better still split it up into two statements.
Vanilla info
To Reproduce
Steps to reproduce the behavior:
Expected behavior
for count to update correctly without error
The text was updated successfully, but these errors were encountered: