Skip to content
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

DOC Move orderBy docs to raw SQL section. #353

Conversation

GuySartorelli
Copy link
Member

@GuySartorelli GuySartorelli commented Sep 26, 2023

We shouldn't encourage using orderBy() for random sorting - that's what the shuffle() abstraction is for.
Instead, don't mention orderBy() at all until the dedicated raw SQL section.

Issue

Comment on lines -314 to -315
Note that we've used the `orderBy()` method here. This is because `sort()` doesn't allow sorting by raw SQL, which is necessary to use a random sort. Be careful whenever you use the `orderBy()` method to ensure you don't pass in any values you can't trust.
[/warning]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small question. Should we completely remove this statement or we could also move it in "Order by" section?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of this is incorrectly saying you need to use raw SQL to do a random sort, but that's what the shuffle() method is for.
The rest of this is saying that raw SQL is inherently risky, which is already stated in the raw SQL section.

Basically, I don't think there's anything here that we need to keep.

Copy link
Contributor

@sabina-talipova sabina-talipova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@sabina-talipova sabina-talipova merged commit 61a916f into silverstripe:5.1 Sep 28, 2023
@sabina-talipova sabina-talipova deleted the pulls/5.1/update-orderby-docs branch September 28, 2023 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants