mirror of
https://github.com/bitechdev/ResolveSpec.git
synced 2025-11-13 18:03:53 +00:00
Proper handling of x-preload-col-where
This commit is contained in:
parent
d9cf23b1dc
commit
1db1b924ef
@ -146,7 +146,12 @@ func (h *Handler) parseOptionsFromHeaders(r common.Request) ExtendedRequestOptio
|
|||||||
|
|
||||||
// Joins & Relations
|
// Joins & Relations
|
||||||
case strings.HasPrefix(normalizedKey, "x-preload"):
|
case strings.HasPrefix(normalizedKey, "x-preload"):
|
||||||
h.parsePreload(&options, decodedValue)
|
if strings.HasSuffix(normalizedKey, "-where") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
whereClaude := headers[fmt.Sprintf("%s-where", key)]
|
||||||
|
h.parsePreload(&options, decodedValue, decodeHeaderValue(whereClaude))
|
||||||
|
|
||||||
case strings.HasPrefix(normalizedKey, "x-expand"):
|
case strings.HasPrefix(normalizedKey, "x-expand"):
|
||||||
h.parseExpand(&options, decodedValue)
|
h.parseExpand(&options, decodedValue)
|
||||||
case strings.HasPrefix(normalizedKey, "x-custom-sql-join"):
|
case strings.HasPrefix(normalizedKey, "x-custom-sql-join"):
|
||||||
@ -341,7 +346,15 @@ func (h *Handler) mapSearchOperator(colName, operator, value string) common.Filt
|
|||||||
|
|
||||||
// parsePreload parses x-preload header
|
// parsePreload parses x-preload header
|
||||||
// Format: RelationName:field1,field2 or RelationName or multiple separated by |
|
// Format: RelationName:field1,field2 or RelationName or multiple separated by |
|
||||||
func (h *Handler) parsePreload(options *ExtendedRequestOptions, value string) {
|
func (h *Handler) parsePreload(options *ExtendedRequestOptions, values ...string) {
|
||||||
|
if len(values) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
value := values[0]
|
||||||
|
whereClause := ""
|
||||||
|
if len(values) > 1 {
|
||||||
|
whereClause = values[1]
|
||||||
|
}
|
||||||
if value == "" {
|
if value == "" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -358,6 +371,7 @@ func (h *Handler) parsePreload(options *ExtendedRequestOptions, value string) {
|
|||||||
parts := strings.SplitN(preloadStr, ":", 2)
|
parts := strings.SplitN(preloadStr, ":", 2)
|
||||||
preload := common.PreloadOption{
|
preload := common.PreloadOption{
|
||||||
Relation: strings.TrimSpace(parts[0]),
|
Relation: strings.TrimSpace(parts[0]),
|
||||||
|
Where: whereClause,
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(parts) == 2 {
|
if len(parts) == 2 {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user