From 8ef09e356c191836286fbd1d15430b7aa240ad37 Mon Sep 17 00:00:00 2001 From: Jason Kulatunga Date: Sun, 3 Mar 2024 10:04:43 -0800 Subject: [PATCH] update inteface{} usage in query with `any` for clarity. --- backend/pkg/database/gorm_repository_query.go | 8 +++++++- backend/pkg/models/query_resource.go | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/backend/pkg/database/gorm_repository_query.go b/backend/pkg/database/gorm_repository_query.go index 0b69a0851..4a29090b8 100644 --- a/backend/pkg/database/gorm_repository_query.go +++ b/backend/pkg/database/gorm_repository_query.go @@ -41,6 +41,10 @@ const TABLE_ALIAS = "fhir" // Can generate simple or complex queries, depending on the SearchParameter type: // // eg. Simple +// SELECT fhir.* +// FROM fhir_observation as fhir, json_each(fhir.code) as codeJson +// +// result = inteface{} ([]database.IFhirResource) // // eg. Complex // SELECT fhir.* @@ -54,6 +58,8 @@ const TABLE_ALIAS = "fhir" // ) // AND (user_id = "6efcd7c5-3f29-4f0d-926d-a66ff68bbfc2") // GROUP BY `fhir`.`id` +// +// results = []map[string]any{} func (gr *GormRepository) QueryResources(ctx context.Context, query models.QueryResource) (interface{}, error) { sqlQuery, err := gr.sqlQueryResources(ctx, query) @@ -62,7 +68,7 @@ func (gr *GormRepository) QueryResources(ctx context.Context, query models.Query } if query.Aggregations != nil && (query.Aggregations.GroupBy != nil || query.Aggregations.CountBy != nil) { - results := []map[string]interface{}{} + results := []map[string]any{} clientResp := sqlQuery.Find(&results) return results, clientResp.Error diff --git a/backend/pkg/models/query_resource.go b/backend/pkg/models/query_resource.go index 88c3f5848..bf099c10b 100644 --- a/backend/pkg/models/query_resource.go +++ b/backend/pkg/models/query_resource.go @@ -27,7 +27,7 @@ type QueryResourceAggregations struct { type QueryResourceAggregation struct { Field string `json:"field"` - Function string `json:"fn"` + Function string `json:"fn"` //built-in SQL aggregation functions (eg. Count, min, max, etc). } func (q *QueryResource) Validate() error {