firebase-tools
firebase-tools copied to clipboard
Emulator indicating MORE_RESULTS_AFTER_LIMIT with NOT_EQUAL query regardless of more results or not
[REQUIRED] Environment info
Using Google Cloud SDK: 482.0.0 with cloud-firestore-emulator: 1.19.7
firebase-tools:
gcloud --version
Google Cloud SDK 482.0.0
app-engine-java 2.0.28
app-engine-python 1.9.113
app-engine-python-extras 1.9.106
beta 2024.06.24
cloud-datastore-emulator 2.3.1
cloud-firestore-emulator 1.19.7
core 2024.06.24
Platform: Mac OS Sonoma 14.5 with an M2 processor
[REQUIRED] Test case
import requests
import json
commit_url = 'http://127.0.0.1:7079/v1/projects/test-app:commit'
payload = {
"mode": "NON_TRANSACTIONAL",
"mutations": [
{
"insert": {
"key": {
"path": [{"kind": "TestModel"}]
},
"properties": {
"name": {
"stringValue": "Cool Name"
}
}
}
}
]
}
payload = json.dumps(payload)
headers = {'Content-Length': f'{len(payload)}', 'Content-Type': 'application/json'}
resp = requests.post(commit_url, headers=headers, data=payload)
query_url = 'http://127.0.0.1:7079/v1/projects/test-app:runQuery'
# As long as there is a filter that uses != that matches at least 1 result
payload = {
"query": {
"kind": [{"name": "TestModel"}],
"filter": {"propertyFilter": {"property": {"name": "name"}, "op": "NOT_EQUAL", "value": {"stringValue": "baz"}}},
"limit": 10
},
}
payload = json.dumps(payload).encode('utf-8')
headers = {'Content-Length': f'{len(payload)}', 'Content-Type': 'application/json'}
# POST request to the emulator
resp = requests.post(query_url, headers=headers, data=payload)
# check response's data
data = resp.json()
# This assertion will fail regardless of more or not
assert data['batch']['moreResults'] != 'MORE_RESULTS_AFTER_LIMIT'
print(data)
[REQUIRED] Steps to reproduce
To reproduce:
- Start firestore emulator in datastore mode
gcloud emulators firestore start --host-port="0.0.0.0:7079" --database-mode=datastore-mode
- Add an entity
- Query for that entity based on a '!=' condition that results to true for the added entity (I have tested with nullValue and stringValue) and limit to something higher than known number of entities (eg 2 in this case)
- Note the return of "MORE_RESULTS_AFTER_LIMIT" regardless of there being more results or not
[REQUIRED] Expected behavior
I would expect that NO_MORE_RESULTS
is returned in the case that there are no more results
[REQUIRED] Actual behavior
MORE_RESULTS_AFTER_LIMIT
is always returned when doing a NOT_EQUAL query that does include at least one result and on the first page