The documentation says, :
“A field exists when it's set to any value, including an empty string (" ")
, null
, and NaN
(not a number). Note that null field values do not match !=
clauses, because x != null
evaluates to undefined.”
Explanation : Yes, even if we add an empty string, null,( supported data type in Firestore
) or NaN, it doesn't mean that the field doesn't exist. It definitely exists and holds one of those values. And coming to when we compare x != null
in where
clauses, x != null
evaluates undefined, but for non-exist fields. And undefined is not a supported data type in Firestore, according to this Firestore supported data type.
So we can compare .where(x!=null)
and it is supported, but it evaluates to undefined for non-existent fields.
As mentioned in similar thread, the version release of v7.21.0 in Firestore JS SDK supports the !=
operator with where
clause from version 7.21.0
But while digging deeper in the documentation, I found that php5 supports !=
operator as you can see in the code snippet, but the php8 does not support !=
operator yet and the workaround is using not-in
instead of it as shown in this code snippet.
Maybe you are trying to use php version >5 and hence the error.
There is already an open issue on this, in GitHub. You may follow the link for updates and changes or you can create a new request here.