Skip to content

Commit e57764b

Browse files
kevinburke1kyleconroy
authored andcommitted
README: add LIMIT 1 to query that should return one (sqlc-dev#99)
7 extra characters ensures that we don't accidentally fetch a bunch of rows into memory and immediately discard them.
1 parent 5bd693f commit e57764b

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
> 🚨
1+
> 🚨
22
>
33
> sqlc is **very new** and under rapid development.
44
>
55
> The code it generates is correct and safe for production use, but
66
> there is currently no guarantee of stability or backwards-compatibility of
77
> the command line interface, configuration file format or generated code.
88
>
9-
> 🚨
9+
> 🚨
1010
1111
# sqlc: A SQL Compiler
1212

1313
> And lo, the Great One looked down upon the people and proclaimed:
14-
>
14+
>
1515
> "SQL is actually pretty great"
1616
1717
sqlc generates **fully-type safe idiomatic Go code** from SQL. Here's how it works:
@@ -56,7 +56,7 @@ CREATE TABLE authors (
5656

5757
-- name: GetAuthor :one
5858
SELECT * FROM authors
59-
WHERE id = $1;
59+
WHERE id = $1 LIMIT 1;
6060

6161
-- name: ListAuthors :many
6262
SELECT * FROM authors
@@ -154,7 +154,7 @@ func (q *Queries) DeleteAuthor(ctx context.Context, id int64) error {
154154

155155
const getAuthor = `-- name: GetAuthor :one
156156
SELECT id, name, bio FROM authors
157-
WHERE id = $1
157+
WHERE id = $1 LIMIT 1
158158
`
159159

160160
func (q *Queries) GetAuthor(ctx context.Context, id int64) (Author, error) {

examples/any.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ In PostgreSQL,
44
[ANY](https://www.postgresql.org/docs/current/functions-comparisons.html#id-1.5.8.28.16)
55
allows you to check if a value exists in an array expression. Queries using ANY
66
with a single parameter will generate method signatures with slices as
7-
arguments.
7+
arguments.
88

99
```sql
1010
CREATE TABLE authors (

0 commit comments

Comments
 (0)