From 4147e302a8d73a883f47ffe13a2f8d7fe6e8f7ea Mon Sep 17 00:00:00 2001 From: whatdoineed2do/Ray Date: Sat, 9 May 2020 15:42:25 +0100 Subject: [PATCH] [SMARTPL] add 'random' in 'order by' clause 'random' tag in 'order by' clause to request SQLite to random select data rows from result set "random 3 pop" { genre is "Pop" and media_kind is music order by random desc limit 3 } --- src/SMARTPL.g | 4 ++++ src/SMARTPL2SQL.g | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/src/SMARTPL.g b/src/SMARTPL.g index d5e4fc21..35ec51e5 100644 --- a/src/SMARTPL.g +++ b/src/SMARTPL.g @@ -37,6 +37,7 @@ ordertag : STRTAG | INTTAG | DATETAG | ENUMTAG + | RANDOMTAG | (XXX)? NeverUsedRule ; @@ -117,6 +118,9 @@ GROUPTAG : 'track_count' | 'album_count' ; +RANDOMTAG : 'random' + ; + INCLUDES : 'includes' ; diff --git a/src/SMARTPL2SQL.g b/src/SMARTPL2SQL.g index b2c151b1..b6f66815 100644 --- a/src/SMARTPL2SQL.g +++ b/src/SMARTPL2SQL.g @@ -345,6 +345,11 @@ ordertag returns [ pANTLR3_STRING result ] $result->append8($result, "f."); $result->appendS($result, $ENUMTAG.text->toUTF8($ENUMTAG.text)); } + | RANDOMTAG + { + $result = $RANDOMTAG.text->factory->newRaw($RANDOMTAG.text->factory); + $result->append8($result, "random()"); + } ; dateval returns [ pANTLR3_STRING result ]