From 05962035b6bfd9d71cb4153ef0cd6cc06a32786e Mon Sep 17 00:00:00 2001 From: Hein Date: Thu, 20 Nov 2025 17:34:46 +0200 Subject: [PATCH] when you specify computed columns without explicitly listing base columns, you'll get all base model column --- pkg/restheadspec/handler.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg/restheadspec/handler.go b/pkg/restheadspec/handler.go index a1777ca..60aeb48 100644 --- a/pkg/restheadspec/handler.go +++ b/pkg/restheadspec/handler.go @@ -260,9 +260,12 @@ func (h *Handler) handleRead(ctx context.Context, w common.ResponseWriter, id st query = query.Table(tableName) } - // Note: X-Files configuration is now applied via parseXFiles which populates - // ExtendedRequestOptions fields (columns, filters, sort, preload, etc.) - // These are applied below in the normal query building process + // If we have computed columns/expressions but options.Columns is empty, + // populate it with all model columns first since computed columns are additions + if len(options.Columns) == 0 && (len(options.ComputedQL) > 0 || len(options.ComputedColumns) > 0) { + logger.Debug("Populating options.Columns with all model columns since computed columns are additions") + options.Columns = reflection.GetModelColumns(model) + } // Apply ComputedQL fields if any if len(options.ComputedQL) > 0 {