Search: Add inline documentation to sortby.RandomExpr()

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer 2024-01-01 16:22:09 +01:00
parent 95584a69ca
commit 0fd3c1790c

View file

@ -15,8 +15,12 @@ const (
func RandomExpr(dialect gorm.Dialect) *gorm.SqlExpr { func RandomExpr(dialect gorm.Dialect) *gorm.SqlExpr {
switch dialect.GetName() { switch dialect.GetName() {
case MySQL: case MySQL:
// A seed integer can be passed as an argument, e.g. "RAND(2342)", to generate
// reproducible pseudo-random values, see https://mariadb.com/kb/en/rand/.
return gorm.Expr("RAND()") return gorm.Expr("RAND()")
case SQLite3: case SQLite3:
// SQLite does not support specifying a seed to generate a deterministic sequence
// of pseudo-random values, see https://www.sqlite.org/lang_corefunc.html#random.
return gorm.Expr("RANDOM()") return gorm.Expr("RANDOM()")
default: default:
return gorm.Expr("RAND()") return gorm.Expr("RAND()")