Skip to content

Is there UUID support? #10

@onx2

Description

@onx2

Is there now (or in the future) UUID support or should I just convert to a string?

pub async fn find_by_id(ctx: &Context<'_>, id: Uuid) -> Result<Option<Organization>> {
    let pool = ctx.data::<PgPool>()?;

    let sql = SqlBuilder::select_from(ORGANIZATION_TABLE_NAME)
        .field("*")
        // Right now I need to convert to a string
        .and_where("id = $1".bind(&id.to_string()))
        .sql()?;

    Ok(sqlx::query_as::<_, Organization>(sql.as_str())
        .fetch_optional(pool)
        .await?)
}

Also, would you recommend using .and_where("id = $1".bind(&SqlName::new(id).safe())) to prevent sql injection since the id is passed from the client or is my understanding of SqlName incorrect?

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