mirror of
https://github.com/bitechdev/ResolveSpec.git
synced 2025-12-31 17:28:58 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1adca4c49b | ||
|
|
eefed23766 |
@@ -165,13 +165,10 @@ func (h *Handler) handleRead(ctx context.Context, w common.ResponseWriter, id st
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a pointer to the model type for database operations
|
|
||||||
modelPtr := reflect.New(modelType).Interface()
|
|
||||||
|
|
||||||
logger.Info("Reading records from %s.%s", schema, entity)
|
logger.Info("Reading records from %s.%s", schema, entity)
|
||||||
|
|
||||||
query := h.db.NewSelect().Model(modelPtr)
|
// Use Table() with the resolved table name (don't use Model() as it would add the table twice)
|
||||||
query = query.Table(tableName)
|
query := h.db.NewSelect().Table(tableName)
|
||||||
|
|
||||||
// Apply column selection
|
// Apply column selection
|
||||||
if len(options.Columns) > 0 {
|
if len(options.Columns) > 0 {
|
||||||
|
|||||||
@@ -197,8 +197,8 @@ func (h *Handler) handleRead(ctx context.Context, w common.ResponseWriter, id st
|
|||||||
|
|
||||||
logger.Info("Reading records from %s.%s", schema, entity)
|
logger.Info("Reading records from %s.%s", schema, entity)
|
||||||
|
|
||||||
query := h.db.NewSelect().Model(modelPtr)
|
// Use Table() with the resolved table name (don't use Model() as it would add the table twice)
|
||||||
query = query.Table(tableName)
|
query := h.db.NewSelect().Table(tableName)
|
||||||
|
|
||||||
// Apply column selection
|
// Apply column selection
|
||||||
if len(options.Columns) > 0 {
|
if len(options.Columns) > 0 {
|
||||||
@@ -695,7 +695,7 @@ func (h *Handler) sendFormattedResponse(w common.ResponseWriter, data interface{
|
|||||||
if options.CleanJSON {
|
if options.CleanJSON {
|
||||||
data = h.cleanJSON(data)
|
data = h.cleanJSON(data)
|
||||||
}
|
}
|
||||||
|
w.SetHeader("Content-Type", "application/json")
|
||||||
// Format response based on response format option
|
// Format response based on response format option
|
||||||
switch options.ResponseFormat {
|
switch options.ResponseFormat {
|
||||||
case "simple":
|
case "simple":
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ func (h *Handler) parseOptionsFromHeaders(r common.Request) ExtendedRequestOptio
|
|||||||
AdvancedSQL: make(map[string]string),
|
AdvancedSQL: make(map[string]string),
|
||||||
ComputedQL: make(map[string]string),
|
ComputedQL: make(map[string]string),
|
||||||
Expand: make([]ExpandOption, 0),
|
Expand: make([]ExpandOption, 0),
|
||||||
|
ResponseFormat: "simple", // Default response format
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get all headers
|
// Get all headers
|
||||||
|
|||||||
Reference in New Issue
Block a user