Let users write three more CEL constructs in the filter field, each compiled to SQL across SQLite/MySQL/Postgres: - Scalar startsWith()/endsWith() on content/filename/mime_type (case-insensitive) - matches() regex: PG ~, MySQL/SQLite REGEXP (Go-backed SQLite fn), validated at compile time via cel.ValidateRegexLiterals() - all() comprehension over tags via per-element subqueries, non-empty required Also: contains() now escapes LIKE metacharacters (%, _, \); cross-dialect render tests plus behavioral tests; cel-go bumped to v0.28.1; new operators surfaced in the frontend shortcut guide.
24 lines
511 B
Go
24 lines
511 B
Go
package sqlite
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestRegexpFunctionMatches(t *testing.T) {
|
|
require.NoError(t, ensureRegexpRegistered())
|
|
|
|
re, err := compileRegexp(`^v\d+$`)
|
|
require.NoError(t, err)
|
|
require.True(t, re.MatchString("v12"))
|
|
require.False(t, re.MatchString("version"))
|
|
|
|
// Caching returns the same compiled instance.
|
|
re2, err := compileRegexp(`^v\d+$`)
|
|
require.NoError(t, err)
|
|
require.Same(t, re, re2)
|
|
|
|
_, err = compileRegexp(`(`)
|
|
require.Error(t, err)
|
|
}
|