Handle NULL in regex criteria (#1208)

This commit is contained in:
WithoutPants
2021-03-16 11:13:14 +11:00
committed by GitHub
parent f7cd9cb00d
commit 7e6127975d
7 changed files with 73 additions and 6 deletions

View File

@@ -356,6 +356,17 @@ func verifyNullString(t *testing.T, value sql.NullString, criterion models.Strin
if criterion.Modifier == models.CriterionModifierNotEquals {
assert.NotEqual(criterion.Value, value.String)
}
if criterion.Modifier == models.CriterionModifierMatchesRegex {
assert.True(value.Valid)
assert.Regexp(regexp.MustCompile(criterion.Value), value)
}
if criterion.Modifier == models.CriterionModifierNotMatchesRegex {
if !value.Valid {
// correct
return
}
assert.NotRegexp(regexp.MustCompile(criterion.Value), value)
}
}
func verifyString(t *testing.T, value string, criterion models.StringCriterionInput) {