mirror of
https://github.com/bitechdev/ResolveSpec.git
synced 2026-01-20 01:24:25 +00:00
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:
@@ -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
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user