Skip to content

Allow inserting null values #203

Closed
@Magnuti

Description

@Magnuti

Having a table that looks like this

CREATE TABLE IF NOT EXISTS "public"."items" (
    "id" "uuid" DEFAULT "gen_random_uuid"() NOT NULL,
    "user_id" "uuid" NOT NULL,
    "name" "uuid"
);

It should be possible to write

let toInsert = items.map { item in
    InsertDTO(
        user_id: userId,
        name: item.name, // Can be nil
    )
}

try await supabaseClient.database.from("items")
    .insert(toInsert)
    .execute()

However this is not possible since I get the error invalid input syntax for type uuid: "NULL".

My solution has been to insert twice; once for the items with name present and once for the items with name as nil. But this does not seem optimal.

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