Hello everyone. I have a question with regards to ...
# supabase-kt
c
Hello everyone. I have a question with regards to the documentation. In the section for Insert, it states that "By default, every time you run
insert()
, the client library will make a
select
to return the full record".
Is this accurate? In the same example when it shows how to return the record it has to manually call
select()
. And then when I am testing this myself, no matter what I do, I am not able to get the inserted record from the DB. 🥲. Just to be sure I even disabled RLS. I can see the entry being added to the DB but it is not being returned to the client.
j
Yes, the docs explanation seems to be wrong and the samples are right. Can you share the used code?
c
Here is my code. I am testing against a local environment for now.
Copy code
val userRequest = CreateUserEntity(
    username = name,
)
val createdUser = postgrest.from(COLLECTION)
    .insert(userRequest) {
        single()
    }
    .decodeAs<UserEntity>()
logD(TAG, "User created userId=%S", createdUser.id)
I can see that the row is being added to the DB on each operation, I can see it from the web dashboard. And I also confirmed that I can SELECT from the table, so that seems to indicate not a permissions issue. 🤔 I also tried:
Copy code
val userRequest = CreateUserEntity(
    username = name,
)
val createdUser = postgrest.from(COLLECTION)
    .insert(userRequest) {
        single()
    }
    .decodeSingle<UserEntity>()
logD(TAG, "User created userId=%S", createdUser.id)
And in both cases I got an EOF,
Copy code
kotlinx.serialization.json.internal.JsonDecodingException: Expected start of the object '{', but had 'EOF' instead at path: $
JSON input:
Which tells me I am not getting anything back. I am currently using client library version
2.5.4-wasm0
and I am testing on a JVM target.
j
single()
Its
select()
, not
single()
c
Thanks for the clarification! It was right on my face and I missed it. Next time I should make sure to get my coffee before starting to work.
Also for next time I should look at the samples, there is a loot of good examples there.
j
Thanks for the clarification! It was right on my face and I missed it. Next time I should make sure to get my coffee before starting to work.
No problem, can happen to anyone!