mirror of
https://github.com/bitechdev/ResolveSpec.git
synced 2025-12-30 08:14:25 +00:00
More fixes for _request
This commit is contained in:
@@ -71,9 +71,9 @@ func (p *NestedCUDProcessor) ProcessNestedCUD(
|
||||
RelationData: make(map[string]interface{}),
|
||||
}
|
||||
|
||||
// Check if data has a crud_request field that overrides the operation
|
||||
// Check if data has a _request field that overrides the operation
|
||||
if requestOp := p.extractCRUDRequest(data); requestOp != "" {
|
||||
logger.Debug("Found crud_request override: %s", requestOp)
|
||||
logger.Debug("Found _request override: %s", requestOp)
|
||||
operation = requestOp
|
||||
}
|
||||
|
||||
@@ -92,8 +92,8 @@ func (p *NestedCUDProcessor) ProcessNestedCUD(
|
||||
regularData := make(map[string]interface{})
|
||||
|
||||
for key, value := range data {
|
||||
// Skip crud_request field in actual data processing
|
||||
if key == "crud_request" {
|
||||
// Skip _request field in actual data processing
|
||||
if key == "_request" {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -162,9 +162,9 @@ func (p *NestedCUDProcessor) ProcessNestedCUD(
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// extractCRUDRequest extracts the crud_request field from data if present
|
||||
// extractCRUDRequest extracts the request field from data if present
|
||||
func (p *NestedCUDProcessor) extractCRUDRequest(data map[string]interface{}) string {
|
||||
if request, ok := data["crud_request"]; ok {
|
||||
if request, ok := data["_request"]; ok {
|
||||
if requestStr, ok := request.(string); ok {
|
||||
return strings.ToLower(strings.TrimSpace(requestStr))
|
||||
}
|
||||
@@ -377,10 +377,10 @@ func (p *NestedCUDProcessor) getTableNameForModel(model interface{}, defaultName
|
||||
}
|
||||
|
||||
// ShouldUseNestedProcessor determines if we should use nested CUD processing
|
||||
// It checks if the data contains nested relations or a crud_request field
|
||||
// It checks if the data contains nested relations or a _request field
|
||||
func ShouldUseNestedProcessor(data map[string]interface{}, model interface{}, relationshipHelper RelationshipInfoProvider) bool {
|
||||
// Check for crud_request field
|
||||
if _, hasCRUDRequest := data["crud_request"]; hasCRUDRequest {
|
||||
// Check for _request field
|
||||
if _, hasCRUDRequest := data["_request"]; hasCRUDRequest {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -396,8 +396,8 @@ func ShouldUseNestedProcessor(data map[string]interface{}, model interface{}, re
|
||||
|
||||
// Check if data contains any fields that are relations (nested objects or arrays)
|
||||
for key, value := range data {
|
||||
// Skip crud_request and regular scalar fields
|
||||
if key == "crud_request" {
|
||||
// Skip _request and regular scalar fields
|
||||
if key == "_request" {
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
@@ -294,7 +294,7 @@ func (h *Handler) handleCreate(ctx context.Context, w common.ResponseWriter, dat
|
||||
|
||||
logger.Info("Creating records for %s.%s", schema, entity)
|
||||
|
||||
// Check if data contains nested relations or crud_request field
|
||||
// Check if data contains nested relations or _request field
|
||||
switch v := data.(type) {
|
||||
case map[string]interface{}:
|
||||
// Check if we should use nested processing
|
||||
@@ -1003,7 +1003,7 @@ func (h *Handler) RegisterModel(schema, name string, model interface{}) error {
|
||||
}
|
||||
|
||||
// shouldUseNestedProcessor determines if we should use nested CUD processing
|
||||
// It checks if the data contains nested relations or a crud_request field
|
||||
// It checks if the data contains nested relations or a _request field
|
||||
func (h *Handler) shouldUseNestedProcessor(data map[string]interface{}, model interface{}) bool {
|
||||
return common.ShouldUseNestedProcessor(data, model, h)
|
||||
}
|
||||
|
||||
@@ -10,15 +10,15 @@ type GormTableSchemaInterface interface {
|
||||
}
|
||||
|
||||
type GormTableCRUDRequest struct {
|
||||
CRUDRequest *string `json:"crud_request"`
|
||||
Request *string `json:"_request"`
|
||||
}
|
||||
|
||||
func (r *GormTableCRUDRequest) SetRequest(request string) {
|
||||
r.CRUDRequest = &request
|
||||
r.Request = &request
|
||||
}
|
||||
|
||||
func (r GormTableCRUDRequest) GetRequest() string {
|
||||
return *r.CRUDRequest
|
||||
return *r.Request
|
||||
}
|
||||
|
||||
// New interfaces that replace the legacy ones above
|
||||
|
||||
@@ -1624,7 +1624,7 @@ func filterExtendedOptions(validator *common.ColumnValidator, options ExtendedRe
|
||||
}
|
||||
|
||||
// shouldUseNestedProcessor determines if we should use nested CUD processing
|
||||
// It checks if the data contains nested relations or a crud_request field
|
||||
// It checks if the data contains nested relations or a _request field
|
||||
func (h *Handler) shouldUseNestedProcessor(data map[string]interface{}, model interface{}) bool {
|
||||
return common.ShouldUseNestedProcessor(data, model, h)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user