Skip to content

Commit 17b403d

Browse files
committed
docs: add more documentation for
1 parent c6c7e0c commit 17b403d

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

docs/howto/embedding.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,24 @@ type ScoreAndTestsRow struct {
5858
Student Student
5959
TestScore TestScore
6060
}
61-
```
61+
```
62+
63+
sqlc can generate structs with fields based on the alias inside the macro `sqlc.embed()` by adding the `emit_embed_alias` key to the configuration file as it shows on [configuration reference](../reference/config.md).
64+
65+
```sql
66+
-- name: ListUserLink :many
67+
SELECT
68+
sqlc.embed(owner),
69+
sqlc.embed(consumer)
70+
FROM
71+
user_links
72+
INNER JOIN users AS owner ON owner.id = user_links.owner_id
73+
INNER JOIN users AS consumer ON consumer.id = user_links.consumer_id;
74+
```
75+
76+
```
77+
type ListUserLinkRow struct {
78+
Owner User
79+
Consumer User
80+
}
81+
```

docs/reference/config.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ The `gen` mapping supports the following keys:
164164
- If true, emit a function per enum type
165165
that returns all valid enum values.
166166
- `emit_embed_alias`:
167-
- If true, use alias name inside `sqlc.embed()` function instead of table name for field name. Defaults to `false`.
167+
- If true, use alias name inside `sqlc.embed()` macro instead of table name for field name. Defaults to `false`.
168168
- `build_tags`:
169169
- If set, add a `//go:build <build_tags>` directive at the beginning of each generated Go file.
170170
- `json_tags_id_uppercase`:
@@ -467,7 +467,7 @@ Each mapping in the `packages` collection has the following keys:
467467
- If true, emit a function per enum type
468468
that returns all valid enum values.
469469
- `emit_embed_alias`:
470-
- If true, use alias name inside `sqlc.embed()` function instead of table name for field name. Defaults to `false`.
470+
- If true, use alias name inside `sqlc.embed()` macro instead of table name for field name. Defaults to `false`.
471471
- `build_tags`:
472472
- If set, add a `//go:build <build_tags>` directive at the beginning of each generated Go file.
473473
- `json_tags_case_style`:

0 commit comments

Comments
 (0)