-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Remove ambiguity in GetUserRepositories SQL #393
Conversation
The indentation looks far too much and beside that the quoting is not database agnostic. |
Sorry about the indentation, i'm not 100% what whitespace characters are used in these files,I just replicated the whitespace characters that existed in vim, which looks fine in vim, but seems odd here. I will fix this. Are you happy with the approach taken?. I think I would prefer to improve it to use some sort of reflection on the Repository struct, but would like to know if the maintainers think this is a good strategy to fix this issue before I spend too much time on it. |
I'm not really happy with this kind of query, but I can't remember real alternatives in mssql beside sub queries. |
I'm not thrilled with it myself, but its what I'm running currently to have gitea usable. Nested selects/sub queries is how I would usually solve this, and would be database agnostic, but from what I can tell xorm doesn't really support them (which makes sense, it should be generating queries). So maybe the issue is upstream with xorm?. Options I've thought to fix this are.
|
I'm totally fine with multi database support, and it's also good that you have skipped the reflection way. I'm just thinking about two queries. One fetching only the unique ids, one to fetch the real repositories. |
I've updated it to do in in two queries like you suggested. I'm not sure whether this function is becoming a bit mammoth now though. |
@lunny suggestions? |
I will give it L-G-T-M after I tested it. @tboerger |
Got conflicts |
Breaks the retrieval of repositories into two queries This fetches the paged ids in one go, then the actual repository information in a second query Some databases do not support SELECT with * when group by is used.
LGTM |
LGTM |
This includes all columns of the repository table in the group by clause
Certain databases will attempt to infer the other columns eg.
https://dev.mysql.com/doc/refman/5.7/en/group-by-handling.html
As some databases supported by xorm don't have the ability to do this
we include every column in the group by clause, this should work the
same assumining repository.id is unique.
This pull request will fix issues viewing the organisation page with #383.