Support native rand() and rand( seed ) in QoQ

Description

HSQLDB has a rand() function that some users use. Put a native rand() implementation into QoQ.

HSQLDB, MySQL, and SQL Server all use the following implementation

The RAND() function returns a random number between 0 and 1 (exclusive).

The optional seed parameter works like so:

If seed is specified, it returns a repeatable sequence of random numbers. If no seed is specified, it returns a completely random number

This means the same Random generator must be re-used for the entire query such that the pseudo-random sequence will always be the same for a given seed value.

Ex:

SELECT rand() differentEveryTime FROM qry

and

SELECT rand(1) setSeed, rand() repeated, rand() repeated2 FROM qry

On repeated executions of the last query, the same random values would always be used for the given seed value of 1.

relates to

Activity

Show:

Brad Wood 17 April 2023 at 18:11

Thank you for helping test!

Pothys - MitrahSoft 17 April 2023 at 14:00
Edited

I checked this issue with lucee version 6.0.0.375-SNAPSHOT. QoQ supports the rand() and rand( seed ) and It works well.

Brad Wood 11 April 2023 at 22:49

Fixed

Details

Assignee

Reporter

Labels

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Sprint

Fix versions

Priority

Created 11 April 2023 at 22:06
Updated 18 April 2023 at 16:16
Resolved 17 April 2023 at 14:00

Flag notifications