MCPcopy
hub / github.com/ent/ent / OrderByRand

Function OrderByRand

dialect/sql/sql.go:396–407  ·  view source on GitHub ↗

OrderByRand returns a term to natively order by a random value.

()

Source from the content-addressed store, hash-verified

394
395// OrderByRand returns a term to natively order by a random value.
396func OrderByRand() func(*Selector) {
397 return func(s *Selector) {
398 s.OrderExprFunc(func(b *Builder) {
399 switch s.Dialect() {
400 case dialect.MySQL:
401 b.WriteString("RAND()")
402 default:
403 b.WriteString("RANDOM()")
404 }
405 })
406 }
407}
408
409// ToFunc returns a function that sets the ordering on the given selector.
410// This is used by the generated code.

Callers 1

SelectFunction · 0.92

Calls 3

OrderExprFuncMethod · 0.80
WriteStringMethod · 0.80
DialectMethod · 0.65

Tested by 1

SelectFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…