[CLOUD_FIRESTORE] where function cannot distinct between null and not setting it for isEqual and isNotEqual #12186
Unanswered
Nourdinait
asked this question in
Q&A
Replies: 1 comment
-
Fixed it now by changing the code to the following:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I try to make a generic functions that takes a Map<String,String> query. This query can look like this {"field": creationDate, "isEqual": null, "isLessThen": 2000} . isEqual is null because it is not set (Just set it in the map for this example). However, the problem is how can you distinct between isEqual being set to null intentionally and isEqual being null because it was not set. In the implementation of the where function isEqual has a default value called notSetQueryParam.
This is the code with the where call.
var dbCommands = db.collection(collection).where(query["field"], isEqualTo: query["isEqualTo"], isNotEqualTo: query["isNotEqualTo"], isLessThan: query["isLessThan"], isLessThanOrEqualTo: query["isLessThanOrEqualTo"], isGreaterThan: query["isGreaterThan"], isGreaterThanOrEqualTo: query["isGreaterThanOrEqualTo"], arrayContains: query["arrayContains"], arrayContainsAny: query["arrayContainsAny"], whereIn: query["whereIn"], whereNotIn: query["whereNotIn"], isNull: query["isNull"]);
calling print(dbCommands.parameters);
Will return {where: [[FieldPath([creationDate]), ==, null], [FieldPath([creationDate]), !=, null],..........
Beta Was this translation helpful? Give feedback.
All reactions