MCPcopy Create free account
hub / github.com/araddon/qlbridge / TestLeftRight

Function TestLeftRight

expr/stringutil_test.go:61–86  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

59}
60
61func TestLeftRight(t *testing.T) {
62 t.Parallel()
63 l, r, hasLeft := LeftRight("`table`.`column`")
64 assert.True(t, l == "table" && hasLeft, "left, right, w quote: %s", l)
65 assert.True(t, r == "column", "left, right, w quote & ns %s", l)
66
67 l, r, hasLeft = LeftRight("`table.column`")
68 assert.True(t, l == "" && !hasLeft, "no left bc escaped %s", l)
69 assert.True(t, r == "table.column", "%s", l)
70
71 // Un-escaped
72 l, r, hasLeft = LeftRight("table.column")
73 assert.True(t, l == "table" && hasLeft, "left, right no quote: %s", l)
74 assert.True(t, r == "column", "left,right, no quote: %s", l)
75
76 // Not sure i want to support this, legacy reasons we stupidly
77 // allowed the left most part before the first period to be the
78 // left, and the rest to be right. Now we should ??? no left?
79 l, r, hasLeft = LeftRight("table.col.with.periods")
80 assert.True(t, l == "table" && hasLeft, "no quote: %s", l)
81 assert.True(t, r == "col.with.periods", "no quote: %s", l)
82
83 l, r, hasLeft = LeftRight("`table.name`.`has.period`")
84 assert.True(t, l == "table.name" && hasLeft, "recognize `left`.`right`: %s", l)
85 assert.True(t, r == "has.period", "no quote: %s", l)
86}

Callers

nothing calls this directly

Calls 1

LeftRightFunction · 0.85

Tested by

no test coverage detected