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.
This commit is contained in:
Tomaž Jerman
2022-09-01 16:55:20 +02:00
parent 0e7f40ca2e
commit 21fe776cc6
+7 -3
View File
@@ -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
}
}
}