Skip to content

Add support for generating code with owned values #73

@banool

Description

@banool

Right now strings and perhaps other types are generated using &'a str:

#[derive(Insertable)]
#[diesel(table_name = blob)]
pub struct NewBlob<'a> {
    pub blob_name: &'a str,
    pub placement_group: &'a str,
    pub size_bytes: BigDecimal,
    pub slice_address: &'a str,
    pub num_chunksets: BigDecimal,
    pub blob_commitment: &'a str,
    pub owner_address: &'a str,
    pub is_written: bool,
    pub is_deleted: bool,
    pub created_ts: DateTime<Utc>,
    pub expires_ts: DateTime<Utc>,
    pub updated_ts: DateTime<Utc>,
    pub updated_txn_version: BigDecimal,
}

For things like batch inserting it can help to create owned versions of these structs, like this:

#[derive(Insertable)]
#[diesel(table_name = blob)]
pub struct NewBlob<'a> {
    pub blob_name: String,
    pub placement_group: String,
    pub size_bytes: BigDecimal,
    pub slice_address: String,
    pub num_chunksets: BigDecimal,
    pub blob_commitment: String,
    pub owner_address: String,
    pub is_written: bool,
    pub is_deleted: bool,
    pub created_ts: DateTime<Utc>,
    pub expires_ts: DateTime<Utc>,
    pub updated_ts: DateTime<Utc>,
    pub updated_txn_version: BigDecimal,
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions