Skip to content

Commit 0596203

Browse files
author
Hein
committed
when you specify computed columns without explicitly listing base columns, you'll get all base model column
1 parent 1cd04b7 commit 0596203

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

pkg/restheadspec/handler.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,12 @@ func (h *Handler) handleRead(ctx context.Context, w common.ResponseWriter, id st
260260
query = query.Table(tableName)
261261
}
262262

263-
// Note: X-Files configuration is now applied via parseXFiles which populates
264-
// ExtendedRequestOptions fields (columns, filters, sort, preload, etc.)
265-
// These are applied below in the normal query building process
263+
// If we have computed columns/expressions but options.Columns is empty,
264+
// populate it with all model columns first since computed columns are additions
265+
if len(options.Columns) == 0 && (len(options.ComputedQL) > 0 || len(options.ComputedColumns) > 0) {
266+
logger.Debug("Populating options.Columns with all model columns since computed columns are additions")
267+
options.Columns = reflection.GetModelColumns(model)
268+
}
266269

267270
// Apply ComputedQL fields if any
268271
if len(options.ComputedQL) > 0 {

0 commit comments

Comments
 (0)