diff --git a/doc.go b/doc.go index b9c99365..5d248d9d 100644 --- a/doc.go +++ b/doc.go @@ -130,7 +130,7 @@ // query results. The edgedb.Optional struct can be embedded to make structs // optional. // -// type User Struct { +// type User struct { // edgedb.Optional // Email string `edgedb:"email"` // } @@ -154,6 +154,19 @@ // Nested structures are also not directly allowed but you can use [json] // instead. // +// By default EdgeDB will ignore embedded structs when marshaling/unmarshaling. +// To treat an embedded struct's fields as part of the parent struct's fields, +// tag the embedded struct with `edgedb:"$inline"`. +// +// type Object struct { +// ID edgedb.UUID +// } +// +// type User struct { +// Object `edgedb:"$inline"` +// Name string +// } +// // # Custom Marshalers // // Interfaces for user defined marshaler/unmarshalers are documented in the diff --git a/internal/cmd/gendocs/rstprinter.go b/internal/cmd/gendocs/rstprinter.go index defb0414..b05a514f 100644 --- a/internal/cmd/gendocs/rstprinter.go +++ b/internal/cmd/gendocs/rstprinter.go @@ -114,5 +114,6 @@ func (p *rstPrinter) text(out *bytes.Buffer, x []comment.Text) { func (p *rstPrinter) escape(out *bytes.Buffer, s string) { s = strings.ReplaceAll(s, "*", "\\*") s = strings.ReplaceAll(s, "\\\\*", "\\*") + s = strings.ReplaceAll(s, "`", "\\`") out.WriteString(s) } diff --git a/rstdocs/index.rst b/rstdocs/index.rst index 8fa66901..123865f8 100644 --- a/rstdocs/index.rst +++ b/rstdocs/index.rst @@ -148,7 +148,7 @@ optional. .. code-block:: go - type User Struct { + type User struct { edgedb.Optional Email string `edgedb:"email"` } @@ -174,6 +174,21 @@ using sets as parameters. Nested structures are also not directly allowed but you can use `json `_ instead. +By default EdgeDB will ignore embedded structs when marshaling/unmarshaling. +To treat an embedded struct's fields as part of the parent struct's fields, +tag the embedded struct with \`edgedb:"$inline"\`. + +.. code-block:: go + + type Object struct { + ID edgedb.UUID + } + + type User struct { + Object `edgedb:"$inline"` + Name string + } + Custom Marshalers -----------------