Skip to content

Commit

Permalink
Document
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastienros committed Nov 7, 2024
1 parent 3aa6ab8 commit 3e1dbdf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/docs/reference/modules/Queries/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,12 @@ The SQL parser is also able to convert some specific functions to the intended d
| `year(_date_)` | Returns the years part of a date. |
| `now()` | Returns current date time (utc). |

Order By clauses can also use the `random()` function (case insensitive) to order results randomly, e.g.,

```
SELECT * FROM ContentItemIndex ORDER BY random()
```

## Scripting

The following JavaScript functions are available with this module.
Expand Down
1 change: 1 addition & 0 deletions test/OrchardCore.Tests/Orchard.Queries/SqlParserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ public void ShouldParseSubquery(string sql, string expectedSql)

[Theory]
[InlineData("select a order by RANDOM()", "SELECT [a] ORDER BY newid();")]
[InlineData("select a order by random()", "SELECT [a] ORDER BY newid();")]
[InlineData("select a order by RANDOM", "SELECT [a] ORDER BY [RANDOM];")]
public void ShouldOrderByRandom(string sql, string expectedSql)
{
Expand Down

0 comments on commit 3e1dbdf

Please sign in to comment.