MCPcopy Create free account
hub / github.com/PostHog/duckgres / TestIsQueryLogSelfReferential

Function TestIsQueryLogSelfReferential

server/querylog_test.go:97–118  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

95 h11 := normalizeQueryHash("SELECT * FROM users WHERE active IS TRUE")
96 h12 := normalizeQueryHash("SELECT * FROM users WHERE active IS NULL")
97 if h11 == h12 {
98 t.Errorf("Expected different hashes for IS TRUE vs IS NULL predicates, both got %d", h11)
99 }
100}
101
102func TestIsQueryLogSelfReferential(t *testing.T) {
103 tests := []struct {
104 query string
105 want bool
106 }{
107 {"SELECT * FROM system.query_log", true},
108 {"SELECT * FROM ducklake.system.query_log ORDER BY event_time DESC", true},
109 {"SELECT * FROM SYSTEM.QUERY_LOG", true},
110 {"SELECT * FROM users", false},
111 {"INSERT INTO logs VALUES (1, 'test')", false},
112 {"SELECT query_log FROM metadata", false}, // "query_log" without "system." prefix is not self-referential
113 }
114
115 for _, tt := range tests {
116 t.Run(tt.query, func(t *testing.T) {
117 got := isQueryLogSelfReferential(tt.query)
118 if got != tt.want {
119 t.Errorf("isQueryLogSelfReferential(%q) = %v, want %v", tt.query, got, tt.want)
120 }
121 })

Callers

nothing calls this directly

Calls 2

RunMethod · 0.65

Tested by

no test coverage detected