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

Function TestSqlRewriteTemp

rel/sql_test.go:145–162  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

143}
144
145func TestSqlRewriteTemp(t *testing.T) {
146
147 s := `SELECT u.user_id, o.item_id, u.reg_date, u.email, o.price, o.order_date FROM users AS u
148 INNER JOIN (
149 SELECT price, order_date, user_id from ORDERS
150 WHERE user_id IS NOT NULL AND price > 10
151 ) AS o
152 ON u.user_id = o.user_id
153 `
154 sql := parseOrPanic(t, s).(*rel.SqlSelect)
155 assert.True(t, len(sql.Columns) == 6, "has 6 cols: %v", len(sql.Columns))
156 assert.True(t, len(sql.From) == 2, "has 2 sources: %v", len(sql.From))
157
158 assert.True(t, sql.String() == `SELECT u.user_id, o.item_id, u.reg_date, u.email, o.price, o.order_date FROM users AS u
159 INNER JOIN (
160 SELECT price, order_date, user_id FROM ORDERS WHERE user_id != NULL AND price > 10
161 ) AS o ON u.user_id = o.user_id`, "Wrong Full SQL?: '%v'", sql.String())
162}
163
164func TestSqlRewrite(t *testing.T) {
165 t.Parallel()

Callers

nothing calls this directly

Calls 2

parseOrPanicFunction · 0.85
StringMethod · 0.65

Tested by

no test coverage detected