From 9522437941ee9bc2b1a82f718e04260e2c19bacc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matou=C5=A1=20Jan=20Fialka?= Date: Wed, 11 Mar 2026 15:17:06 +0100 Subject: [PATCH] [LIQ] Website: Improve general syntax description MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Matouš Jan Fialka --- website/Space Lua/Lua Integrated Query.md | 53 +++++++++++++---------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/website/Space Lua/Lua Integrated Query.md b/website/Space Lua/Lua Integrated Query.md index f1ebe654..ea515e4a 100644 --- a/website/Space Lua/Lua Integrated Query.md +++ b/website/Space Lua/Lua Integrated Query.md @@ -6,34 +6,43 @@ Lua Integrated Query (LIQ) is a SilverBullet specific Lua extension. It adds a c The syntax for LIQ is `query[[my query]]`. In regular Lua `[[my query]]` is just another way of writing `"my query"` (it is an alternative string syntax). Function calls that only take a string argument can omit parentheses, therefore `query[[my query]]` is equivalent to `query("my query")`. -However, in [[Space Lua]] it is interpreted as an SQL (and [LINQ](https://learn.microsoft.com/en-us/dotnet/csharp/linq/))-inspired integrated query language. +However, in [[Space Lua]] it is interpreted as an SQL- and [LINQ](https://learn.microsoft.com/en-us/dotnet/csharp/linq/)-inspired integrated query language. General syntax: - query [[ - from - where - group by [, ...] - having - order by - [asc | desc | using ] - [nulls {first | last}] - [, ...] - limit [, ] - offset - select - ]] +```postgres +query [[ + from <> + [ where <> ] + [ group by <> [, ...] ] + [ having <> ] + [ order by <> [, ...] ] + [ limit <> [, <>] ] + [ offset <> ] + [ select <> ] +]] +``` -Aggregate functions support an optional intra-aggregate `order by` and/or `filter` clause: +Unlike in SQL where clauses must be written in a particular order, LIQ clauses can be written in any order, and the only mandatory clause is the `from` clause. - ( [, ...] - [order by - [asc | desc | using ] - [nulls {first | last}] - [, ...]] - [filter(where )]) +The `order by` clause uses `<>`: -These can be combined. See [[Space Lua/Lua Integrated Query/Aggregating]] for details. +```postgres +<> + [ asc | desc | using <> ] + [ nulls { first | last } ] +``` + +If an aggregate function call is used for projection (`select`), the general syntax is: + +```postgres +<>( <> [, ...] + [ order by <> [, ...] ] + [ filter (where <>) ] +) +``` + +See [[Space Lua/Lua Integrated Query/Aggregating]] for details. LIQ operates on any Lua collection.