adonisjs / lucid

AdonisJS SQL ORM. Supports PostgreSQL, MySQL, MSSQL, Redshift, SQLite and many more
https://lucid.adonisjs.com/
MIT License
1.08k stars 195 forks source link

feat(query_builder): add orderByRandom #1011

Open RomainLanz opened 8 months ago

RomainLanz commented 8 months ago

Hey there! 👋🏻

This PR adds a orderByRandom method to retrieve records in a random order. It defines the right keyword for each dialect.

The test may be flaky, I have set it up to run 3 times in case it fails.

A seed can be pass when using MySQL (same as Laravel implementation).

RomainLanz commented 2 months ago

I am not sure how to deal with the mssql error. We are not passing multiple NEWID() to the order by clause. 🤔