launchbadge/sqlx

Extend derive(FromRow) with additional features/attributes

Open

#156 建立於 2020年3月26日

在 GitHub 查看
 (2 留言) (19 反應) (0 負責人)Rust (13,916 star) (1,307 fork)batch import
E-mediumenhancementgood first issuehelp wanted

描述

  • Handle #[sqlx(rename = "new_name")] on a struct field

  • Support the derive on a tuple struct and use by ordinal retrieval from the row

  • Handle #[sqlx(ordinal = 3)] to use ordinal retrieval from the row ( row.get(3) )

  • Handle a field that is impl FromRow. A parallel from serde_json would perhaps make this #[sqlx(flatten)].

    #[derive(sqlx::FromRow)]
    struct Bar {
        baz: i32  // row.get("baz")
     }
    
    #[derive(sqlx::FromRow)]
    struct Foo {
        foo: i32, // row.get("foo")
        #[sqlx(flatten)]
        bar: Bar
    }
    

貢獻者指南