From 0fd3c1790c75e85ba168e40a62663d316b4ac3ed Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Mon, 1 Jan 2024 16:22:09 +0100 Subject: [PATCH] Search: Add inline documentation to sortby.RandomExpr() Signed-off-by: Michael Mayer --- pkg/sortby/random.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/sortby/random.go b/pkg/sortby/random.go index 0adbfa844..3a79a7b98 100644 --- a/pkg/sortby/random.go +++ b/pkg/sortby/random.go @@ -15,8 +15,12 @@ const ( func RandomExpr(dialect gorm.Dialect) *gorm.SqlExpr { switch dialect.GetName() { 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()") 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()") default: return gorm.Expr("RAND()")