Skip to content

Support serde(flatten) attribute #264

@slvrtrn

Description

@slvrtrn

Use case

After #221 and #244, we still can't support flattened structs such as:

#[derive(Row, Serialize)]
struct Metadata {
    foo: String,
    bar: String,
}

#[derive(Row, Serialize)]
struct MyRow {
    #[serde(flatten)]
    metadata: Metadata,
    data: String,
}

while inserting data to a table like this:

CREATE TABLE test (
  foo  String,
  bar  String,
  data String
)

Currently, with enabled validation, it will complain about number of fields (2 in struct vs 3 in the db), cause currently it will derive only [ "metadata", "data" ], and not [ "foo", "bar", "data" ] as it should have been.

Describe the solution you'd like

To solve this, derive macro needs adjustments to support recursive resolution.

Additional context

See #99, #101 for more details.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions