diff --git a/Documentation/QueryInterfaceOrganization.md b/Documentation/QueryInterfaceOrganization.md index 78e0aa6d8..d7791880b 100644 --- a/Documentation/QueryInterfaceOrganization.md +++ b/Documentation/QueryInterfaceOrganization.md @@ -402,6 +402,16 @@ SQLOrderingTerm feeds the `order()` method of the query interface: Player.order(Column("score").desc, Column("name")) ``` +All [SQLSpecificExpressible] values are ordering terms. [SQLExpressible] values are not: `Player.order("name")` does not compile. Instead, use: + +```swift +// SELECT * FROM player ORDER BY name -- Order according to a column +Player.order(Column("name")) + +// SELECT * FROM player ORDER BY 'name' -- Order according to a constant string (why not) +Player.order("name".databaseValue) +``` + ### SQLOrdering `SQLOrdering` is the opaque type for all [SQLite ordering terms](https://sqlite.org/syntax/ordering-term.html). An SQLOrdering adopts and is built from [SQLOrderingTerm]. @@ -472,6 +482,26 @@ Player.select(AllColumns()) Player.select(Column("name"), Column("score")) ``` +All [SQLSpecificExpressible] values are selectable. Other selectable values are: + +```swift +// SELECT * FROM player +Player.select(AllColumns()) + +// SELECT MAX(score) AS maxScore FROM player +Player.select(max(Column("score")).forKey("maxScore")) +``` + +[SQLExpressible] values are not selectable: `Player.select("name")` does not compile. Instead, use: + +```swift +// SELECT name FROM player -- Selects a column +Player.select(Column("name")) + +// SELECT 'name' FROM player -- Selects a constant string (why not) +Player.select("name".databaseValue) +``` + ### SQLSelection `SQLSelection` is the opaque type for all [SQLite result columns](https://sqlite.org/syntax/result-column.html). An SQLSelection adopts and is built from [SQLSelectable].