feat(restheadspec): Add support for join aliases in filters and sorts

- Extract join aliases from custom SQL JOIN clauses.
- Validate join aliases for filtering and sorting operations.
- Update documentation to reflect new functionality.
- Enhance tests for alias extraction and usage.
This commit is contained in:
Hein
2026-01-15 14:18:25 +02:00
parent b87841a51c
commit 24a7ef7284
5 changed files with 242 additions and 0 deletions

View File

@@ -233,6 +233,27 @@ x-custom-sql-join: LEFT JOIN departments d ON d.id = e.dept_id | INNER JOIN role
- Multiple JOINs can be specified using the pipe `|` separator
- JOINs are sanitized for security
- Can be specified via headers or query parameters
- **Table aliases are automatically extracted and allowed for filtering and sorting**
**Using Join Aliases in Filters and Sorts:**
When you specify a custom SQL join with an alias, you can use that alias in your filter and sort parameters:
```
# Join with alias
x-custom-sql-join: LEFT JOIN departments d ON d.id = employees.department_id
# Sort by joined table column
x-sort: d.name,employees.id
# Filter by joined table column
x-searchop-eq-d.name: Engineering
```
The system automatically:
1. Extracts the alias from the JOIN clause (e.g., `d` from `departments d`)
2. Validates that prefixed columns (like `d.name`) refer to valid join aliases
3. Allows these prefixed columns in filters and sorts
---