Skip to content

Commit f49221d

Browse files
Copilothotlong
andcommitted
Address code review: Document nested expand limitation
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 5e670aa commit f49221d

2 files changed

Lines changed: 28 additions & 7 deletions

File tree

packages/protocols/odata-v4/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,17 @@ curl "http://localhost:8080/odata/orders?\$expand=items(\$filter=status eq 'acti
192192
curl "http://localhost:8080/odata/orders?\$expand=customer(\$select=name,email)"
193193
```
194194

195+
**Supported expand options:**
196+
- `$filter` - Filter expanded entities
197+
- `$select` - Select specific fields from expanded entities
198+
- `$orderby` - Sort expanded entities
199+
- `$top` - Limit number of expanded entities
200+
201+
**Current Limitations:**
202+
- ⚠️ Nested expand (e.g., `$expand=owner($expand=department)`) is not yet supported
203+
- Only single-level relationship expansion is available
204+
- See [Phase 2 Roadmap](../../../PROTOCOL_DEVELOPMENT_PLAN_ZH.md) for planned nested expand support
205+
195206
Response includes expanded entities:
196207
```json
197208
{

packages/protocols/odata-v4/src/index.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -567,11 +567,18 @@ export class ODataV4Plugin implements RuntimePlugin {
567567
* Expand navigation properties for OData $expand
568568
*
569569
* Implements OData V4 $expand feature to include related entities in the response.
570-
* Supports:
571-
* - Single property expand: $expand=owner
572-
* - Multiple properties: $expand=owner,department
573-
* - Nested expand: $expand=owner($expand=department)
574-
* - Expand with options: $expand=orders($filter=status eq 'active')
570+
*
571+
* **Current Support**:
572+
* - ✅ Single property expand: $expand=owner
573+
* - ✅ Multiple properties: $expand=owner,department
574+
* - ✅ Expand with options: $expand=orders($filter=status eq 'active')
575+
* - ✅ Supported options: $filter, $select, $orderby, $top
576+
*
577+
* **Limitations** (Phase 2 roadmap):
578+
* - ⚠️ Nested expand not yet supported: $expand=owner($expand=department)
579+
* - ⚠️ Only single-level relationship expansion
580+
*
581+
* See PROTOCOL_DEVELOPMENT_PLAN_ZH.md Phase 2 for nested expand implementation.
575582
*
576583
* @param entitySet - The main entity set name
577584
* @param entities - Array of entities to expand properties for
@@ -589,16 +596,19 @@ export class ODataV4Plugin implements RuntimePlugin {
589596
}
590597

591598
// Parse the expand parameter (simple implementation - handles comma-separated properties)
592-
// TODO: In future, support nested expands with parentheses: owner($expand=department)
599+
// Note: Nested expands (e.g., owner($expand=department)) are not yet supported
600+
// and will be rejected by the regex pattern below
593601
const expandProperties = expandParam.split(',').map(p => p.trim());
594602

595603
// For each expand property, fetch related data
596604
for (const propertyName of expandProperties) {
597605
// Parse property name and options (basic implementation)
598606
// Format: propertyName or propertyName($filter=...$select=...)
607+
// Nested expands with multiple levels are NOT supported in this version
599608
const propMatch = propertyName.match(/^(\w+)(?:\(([^)]+)\))?$/);
600609
if (!propMatch) {
601-
continue; // Skip invalid property syntax
610+
// Invalid syntax or nested expand detected - skip
611+
continue;
602612
}
603613

604614
const [, fieldName, options] = propMatch;

0 commit comments

Comments
 (0)