Skip to content

Conversation

@manikanta5827
Copy link
Contributor

Fix: Optional Fields Filter

Issue

When querying records with optional fields, records missing those fields were incorrectly included in results.

Example:

// Data
{ "id": "1", "name": "test 1", "optionalField": "A" }
{ "id": "2", "name": "test 2" }  // missing optionalField

// Query: GET /records?optionalField=A
// Before: returned both records
// After: returns only record 1

Solution

Added case 'undefined': return false in the default condition switch statement to properly filter out records with missing fields.

Code Change

file :: src/service.ts line :: 308

case Condition.default: {
  switch (typeof itemValue) {
    case 'number':
      return itemValue === parseInt(paramValue)
    case 'string':
      return itemValue === paramValue
    case 'boolean':
      return itemValue === (paramValue === 'true')
    case 'undefined':
      return false  // ← New line
  }
}

Fixes #1647

@typicode
Copy link
Owner

Thank you!

@typicode typicode merged commit 90c0734 into typicode:main Sep 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Optional Fields are not filtered out with default condition.

2 participants