-
-
Notifications
You must be signed in to change notification settings - Fork 178
Firestore customizable encoding for where clauses and update methods #607
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
Firestore customizable encoding for where clauses and update methods #607
Conversation
It had become part of commons-internal which kind of defeats the purpose. Also made FirebaseEncoder/FirebaseDecoder an interface in the public API. Useful for writing custom Serializers that have custom behaviour on Firebase
…er' into feature/field-value-encoding
I still need to add Readme/some tests, but feedback would already be appreciated @nbransby as I wont be able to continue until next week |
This reverts commit 4176fe6.
Will anyone ever review this @nbransby 😅 |
Sorry been a crazy month, will hopefully get to it soon |
Does that make this a breaking change? |
looks great to me, I would like to see more comprehensive documentation in the README that would also help me understand the intended usage. |
Yeah, its breaking. I went from:
to
The reason I had to do something is because the new update method has the signature:
and since the original method takes a vararg, it can be called as
I think 1 is a definitive no-go. If you prefer we do 2, Im fine with that as well. Its always gonna be a tradeoff so its pick your poison basically. As for documentation, Ill change that as soon as we agree on this point :) |
I spent long enough trying to think of additional alternatives without joy so, I favour 2 and calling it |
Done @nbransby |
public final class dev/gitlive/firebase/FirebaseEncoder$DefaultImpls { | ||
public static fun beginCollection (Ldev/gitlive/firebase/FirebaseEncoder;Lkotlinx/serialization/descriptors/SerialDescriptor;I)Lkotlinx/serialization/encoding/CompositeEncoder; | ||
public static fun encodeNotNullMark (Ldev/gitlive/firebase/FirebaseEncoder;)V | ||
public static fun encodeNullableSerializableValue (Ldev/gitlive/firebase/FirebaseEncoder;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;)V | ||
public static fun encodeSerializableValue (Ldev/gitlive/firebase/FirebaseEncoder;Lkotlinx/serialization/SerializationStrategy;Ljava/lang/Object;)V | ||
} | ||
|
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.
does all the DefaultImpls need to be exposed?
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.
Looks like this is coming in from Kotlin. By extending the Encoder interface we inherit some default implementations. This is what that looks like from a JVM api perspective. There is no "DefaultImpls" class anywhere, the file is literally this:
public interface FirebaseEncoder : Encoder
public final class dev/gitlive/firebase/EncodeDecodeSettingsKt { | ||
public static final fun copyFrom (Ldev/gitlive/firebase/DecodeSettings$Builder;Ldev/gitlive/firebase/DecodeSettings$Builder;)V | ||
public static final fun copyFrom (Ldev/gitlive/firebase/EncodeSettings$Builder;Ldev/gitlive/firebase/EncodeSettings$Builder;)V | ||
} |
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.
does this need to be public?
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.
No, removed
@@ -576,117 +610,92 @@ public abstract interface class dev/gitlive/firebase/firestore/WhereConstraint { | |||
} | |||
|
|||
public final class dev/gitlive/firebase/firestore/WhereConstraint$ArrayContains : dev/gitlive/firebase/firestore/WhereConstraint$ForObject { | |||
public final fun component1 ()Ljava/lang/Object; | |||
public fun <init> (Lkotlin/jvm/functions/Function0;)V |
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.
exposing constructor?
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.
FilterBuilder uses it in its inline implementation. Marked as internal @PublishedAPI in code, so not actually visible for the kotlin side
does |
@nbransby @Reedyuk Sorry for the looooooong delay in picking this up. Priorities just got in the way so I never got around to addressing this. I've tracked latest master, corrected the readme and where possible moved things out of the public API. On On some of the things in the API: see individual comments. |
@Daeda88 is this still a thing? If so, it would be really nice if you rebase and create a PR here: https://github.com/DatL4g/firebase-kotlin-sdk |
@Daeda88 looks good, lets deprecate the old methods ( |
Ok, I'm on holiday the upcoming week, will do that when I'm back |
@nbransby added deprecation/updateWith annotation. Hope its finally good to go! (almost exactly a year further but worth it 😂 ) |
Glad to see its approved. Im assuming you're holding of on merging due to the CI issue, but I have no idea what's causing it as API dump doesnt trigger any changes for me locally |
@Reedyuk any ideas on that? |
Seems to be that there is changes it wants to push but doesn't have the permission to push. |
Im not sure if @Daeda88 is on a mac, but it could be that we generate the ios api too now, whereas previously it was only done on jvm and js |
@Reedyuk API is only for JVM targets (android/jvm) and I am running on Mac regardless. So that cant be it. Running it now with a git status command to see what its trying to commit. Also, what's the point of the auto commit task if it doesnt work? |
Fixes #604 and trumps #605
This solution extends all update methods in Firestore to support more advanced update methods. String fields and FieldPaths can now be used interchangably and custom serializer can be passed.
becomes
Note that the existing vararg pairs can still be used.
Similar support has been added to
where
clauses as well asstartAt
/endAt
/etc:There is a small regression on the existing update methods in that
public fun update(documentRef: DocumentReference, vararg fieldsAndValues: Pair<String, Any?>, buildSettings: EncodeSettings.Builder.() -> Unit)
changed topublic fun update(documentRef: DocumentReference, buildSettings: EncodeSettings.Builder.() -> Unit, vararg fieldsAndValues: Pair<String, Any?>)
due to Kotlin not being able to figure out which update method to use.Furthermore, I've split the Firestore tests into a few different files and extended them so they clean up all data after completion.
Lastly, I discovered bug #613 and fixed it