From 21fe776cc67380233ab45d6470336ad7b003ee3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toma=C5=BE=20Jerman?= Date: Thu, 1 Sep 2022 14:41:38 +0200 Subject: [PATCH] Cover nil panic when the filter doesn't define any constraints The RDBMS/dal SQL builder merged model-defined constraints and filter defined constraints. Now that model-defined constraints are no longer guaranteed, it was panicing. --- store/adapters/rdbms/dal/model.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/store/adapters/rdbms/dal/model.go b/store/adapters/rdbms/dal/model.go index 0b7955e02..09653d7a9 100644 --- a/store/adapters/rdbms/dal/model.go +++ b/store/adapters/rdbms/dal/model.go @@ -255,9 +255,13 @@ func (d *model) searchSql(f filter.Filter) *goqu.SelectDataset { cc := f.Constraints() if d.model.Constraints != nil { - for k, c := range d.model.Constraints { - // Overwrite user-provided constraints as the system ones are more important - cc[k] = c + if cc == nil { + cc = d.model.Constraints + } else { + for k, c := range d.model.Constraints { + // Overwrite user-provided constraints as the system ones are more important + cc[k] = c + } } }