Skip to content

How to insert nullable values? #93

Closed
@D1plo1d

Description

@D1plo1d

I am using Option<String> to represent a nullable String but my code bellow complains that it expected a String instead of Option. How should nullable values be written with sqlx?

My code that doesn't work:

let name = Some("D1plo1d");
sqlx::query!(
    "INSERT INTO users (name) VALUES ($1)",
    name
);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions