MCPcopy
hub / github.com/pocketbase/pocketbase / TestFilterDataBuildExpr

Function TestFilterDataBuildExpr

tools/search/filter_test.go:16–180  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

14)
15
16func TestFilterDataBuildExpr(t *testing.T) {
17 resolver := search.NewSimpleFieldResolver("test1", "test2", "test3", `^test4_\w+$`, `^test5\.[\w\.\:]*\w+$`)
18
19 scenarios := []struct {
20 name string
21 filterData search.FilterData
22 expectError bool
23 expectPattern string
24 }{
25 {
26 "empty",
27 "",
28 true,
29 "",
30 },
31 {
32 "invalid format",
33 "(test1 > 1",
34 true,
35 "",
36 },
37 {
38 "invalid operator",
39 "test1 + 123",
40 true,
41 "",
42 },
43 {
44 "unknown field",
45 "test1 = 'example' && unknown > 1",
46 true,
47 "",
48 },
49 {
50 "simple expression",
51 "test1 > 1",
52 false,
53 "[[test1]] > {:TEST}",
54 },
55 {
56 "empty string vs null",
57 "'' = null && null != ''",
58 false,
59 "('' = '' AND '' IS NOT '')",
60 },
61 {
62 "like with 2 columns",
63 "test1 ~ test2",
64 false,
65 "[[test1]] LIKE ('%' || [[test2]] || '%') ESCAPE '\\'",
66 },
67 {
68 "like with right column operand",
69 "'lorem' ~ test1",
70 false,
71 "{:TEST} LIKE ('%' || [[test1]] || '%') ESCAPE '\\'",
72 },
73 {

Callers

nothing calls this directly

Calls 4

NewSimpleFieldResolverFunction · 0.92
RunMethod · 0.45
BuildExprMethod · 0.45
BuildMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…