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

Method writeDialectDepth

rel/sql.go:1337–1390  ·  view source on GitHub ↗
(depth int, w expr.DialectWriter)

Source from the content-addressed store, hash-verified

1335 m.writeDialectDepth(0, w)
1336}
1337func (m *SqlSource) writeDialectDepth(depth int, w expr.DialectWriter) {
1338
1339 if int(m.Op) == 0 && int(m.LeftOrRight) == 0 && int(m.JoinType) == 0 {
1340 if m.Alias != "" {
1341 w.WriteIdentity(m.Name)
1342 io.WriteString(w, " AS ")
1343 w.WriteIdentity(m.Alias)
1344 return
1345 }
1346 if m.Schema == "" {
1347 w.WriteIdentity(m.Name)
1348 } else {
1349 w.WriteIdentity(m.Schema)
1350 io.WriteString(w, ".")
1351 w.WriteIdentity(m.Name)
1352 }
1353 return
1354 }
1355
1356 // Jointype Op
1357 // INNER JOIN orders AS o ON
1358 if int(m.JoinType) != 0 {
1359 io.WriteString(w, strings.ToTitle(m.JoinType.String())) // inner/outer
1360 io.WriteString(w, " ")
1361 }
1362 io.WriteString(w, "JOIN ")
1363
1364 if m.SubQuery != nil {
1365 io.WriteString(w, "(\n"+strings.Repeat("\t", depth+1))
1366 m.SubQuery.writeDialectDepth(depth+1, w)
1367 io.WriteString(w, "\n"+strings.Repeat("\t", depth)+")")
1368 } else {
1369 if m.Schema == "" {
1370 w.WriteIdentity(m.Name)
1371 } else {
1372 w.WriteIdentity(m.Schema)
1373 io.WriteString(w, ".")
1374 w.WriteIdentity(m.Name)
1375 }
1376
1377 }
1378 if m.Alias != "" {
1379 io.WriteString(w, " AS ")
1380 w.WriteIdentity(m.Alias)
1381 }
1382
1383 io.WriteString(w, " ")
1384 io.WriteString(w, strings.ToTitle(m.Op.String()))
1385
1386 if m.JoinExpr != nil {
1387 w.Write([]byte{' '})
1388 m.JoinExpr.WriteDialect(w)
1389 }
1390}
1391
1392func (m *SqlSource) BuildColIndex(colNames []string) error {
1393 if len(m.colIndex) == 0 {

Callers 1

WriteDialectMethod · 0.95

Calls 4

WriteIdentityMethod · 0.65
StringMethod · 0.65
WriteDialectMethod · 0.65
writeDialectDepthMethod · 0.45

Tested by

no test coverage detected