MCPcopy
hub / github.com/pocketbase/pocketbase / TestAliasOrIdentifier

Function TestAliasOrIdentifier

tools/dbutils/select_test.go:9–38  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func TestAliasOrIdentifier(t *testing.T) {
10 scenarios := []struct {
11 value string
12 expected string
13 }{
14 {"", ""},
15 {"abc", "abc"},
16 {"abc ", "abc "}, // return unmodified
17 {"abc.def", "abc.def"},
18 {"abc.123 def", "def"},
19 {"abc.123 as def.456", "def.456"},
20 {"(abc) def", "def"},
21 {"(abc) as def", "def"},
22 {"abc def", "def"},
23 {"abc as def", "def"},
24 // technically invalid identifier but consistent with the dbx regex matching
25 {"a b c d", "d"},
26 {"a b c as d", "d"},
27 }
28
29 for _, s := range scenarios {
30 t.Run(s.value, func(t *testing.T) {
31 result := dbutils.AliasOrIdentifier(s.value)
32
33 if result != s.expected {
34 t.Fatalf("Expected\n%v\ngot\n%v", s.expected, result)
35 }
36 })
37 }
38}

Callers

nothing calls this directly

Calls 2

AliasOrIdentifierFunction · 0.92
RunMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…