Skip to content

Commit

Permalink
docs: clarify the difference between a query and a fragment
Browse files Browse the repository at this point in the history
  • Loading branch information
gajus committed Dec 3, 2024
1 parent 2d3c401 commit 9e3d5ea
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1787,7 +1787,12 @@ sql.typeAlias('id')`
`
```
The only difference between queries and fragments is that fragments are untyped and they cannot be used as inputs to query methods (use `sql.type` instead).
#### Fragments vs Queries
There are two primary differences:
* Fragments are untyped and they cannot be used as inputs to query methods (use `sql.type` instead).
* Queries are expected to be valid SQL if executed (e.g. `SELECT * FROM foo`); fragments are expected to be valid _fragments_ of SQL (e.g. `WHERE bar = 1`).
> [!WARNING]
> Due to the way that Slonik internally represents SQL fragments, your query must not contain `$slonik_` literals.
Expand Down

0 comments on commit 9e3d5ea

Please sign in to comment.