-
-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Closed
Description
Issue
When querying with the default condition "=" on an optional field, records without this field appear in the result list.
Expected Result
Only records which contain that optional field and matching its value to the condition appear in the result list.
Example
db.json:
{
"test-records": [
{
"id": "1",
"name": "test 1 with optional field A",
"optionalField": "A"
},
{
"id": "2",
"name": "test 2 with optional field B",
"optionalField": "B"
},
{
"id": "3",
"name": "test 3 without optional field"
}
]
}
Request:
http://localhost:3000/test-records?optionalField=A
Current Response:
[
{
"id": "1",
"name": "test 1 with optional field A",
"optionalField": "A"
},
{
"id": "3",
"name": "test 3 without optional field"
}
]
json-server version: 1.0.0-beta.3
Possible code location of issue
At json-server/src/service.ts in the block starting at line 300 (case Condition.default:), itemValue is not tested for undefined and therefor code is processed until line 312 which returns true.
Metadata
Metadata
Assignees
Labels
No labels