supabase / supabase-swift

A Swift client for Supabase
https://supabase.com/docs/reference/swift
MIT License
682 stars 100 forks source link

Integers (0 or 1) in JSONBs are automatically converted to Bool undesirably #533

Open pedrommcarrasco opened 2 days ago

pedrommcarrasco commented 2 days ago

Bug report

Describe the bug

With the following Codable object:

struct Model: Codable {
    var id: String
    var quantities: [String: Int]
}

When doing bulk upserts, the following object:

let model = Model(id: "1", quantities: ["holo": 1])

Will undesirably have its jsonb property with:

{
    "id": "1",
    "quantities": {
        "holo": true
    }
}

Expected behavior

The expected behaviour should be

{
    "id": "1",
    "quantities": {
        "holo": 1
    }
}

System information

pedrommcarrasco commented 2 days ago

I can also reproduce this issue on the Supabase Website via the Table Editor. Would love to hear more as this is currently breaking my code.

dshukertjr commented 18 hours ago

@pedrommcarrasco I couldn't reproduce this on the table editor, but what is the procedure you took?

I created a jsonb column in a table, and inserted {"a": 1} as value from the table editor. When I refresh the page, I see {"a": 1} as the value. I also tried inserting {"a": true}, but I got {"a": true} as well.

pedrommcarrasco commented 3 hours ago

@pedrommcarrasco I couldn't reproduce this on the table editor, but what is the procedure you took?

I was able to reproduce it on the table editor at the time of writing but now, after doing a bunch of changes to work around this, I'm unable to do it again. I'll try to go back to the original conditions later this week.