-
-
Notifications
You must be signed in to change notification settings - Fork 74
Add the possibility to have a multi-column PK in realtime #614
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the possibility to have a multi-column PK in realtime #614
Conversation
Realtime/src/commonMain/kotlin/io/github/jan/supabase/realtime/RealtimeExt.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, it seems this might take more changes than expected. You can fix the selectAsFlow method by just taking the primary key values and combining them yourself. Something like this:
cache.remove(primaryKeys.map { key -> it.oldRecord[key.columnName]?.jsonPrimitive?.content }.joinToString(""))(not sure if that works exactly).
For the single flow variant, I'm not sure if that's possible as we can only provide one filter for realtime
Realtime/src/commonMain/kotlin/io/github/jan/supabase/realtime/RealtimeExt.kt
Outdated
Show resolved
Hide resolved
Realtime/src/commonMain/kotlin/io/github/jan/supabase/realtime/RealtimeExt.kt
Outdated
Show resolved
Hide resolved
I made the changes. Can you test that again? 🙏🏻 |
jan-tennert
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think that should work. Can you add List<KProperty1<Data, Value>> overloads (like the other overload for PrimaryKey, so you can just use this syntax: selectAsFlow(listOf(Message::id, Message::channelId))
Oh, I don't know why I missed those. Done ✅. |
|
Also, I normally just use the blank |
Realtime/src/commonMain/kotlin/io/github/jan/supabase/realtime/PostgrestExtensions.kt
Show resolved
Hide resolved
…zmar/supabase-kt into multi_column_pk_on_realtime
jan-tennert
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! I'm going to include this in the upcoming 2.5.0 beta, so you can try it out yourself!
What kind of change does this PR introduce?
Feature
What is the current behavior?
The realtime API doesn't allow to have a multi-column PK.
What is the new behavior?
The realtime API now works with multi-column PKs.
Additional context
https://kotlinlang.slack.com/archives/C06QXPC7064/p1716652456870609
I couldn't really test this. What's the usual strategy to test the library?