(astExpr ast.Expr, array bool, body ast.Seq, inType super.Type)
| 1287 | } |
| 1288 | |
| 1289 | func (t *translator) subqueryExpr(astExpr ast.Expr, array bool, body ast.Seq, inType super.Type) (*sem.SubqueryExpr, super.Type) { |
| 1290 | // We pass inType in whether or not it's correlated since an uncorrelated |
| 1291 | // subquery will just ignore it. |
| 1292 | seq, outType := t.seq(body, inType) |
| 1293 | correlated := isCorrelated(seq) |
| 1294 | e := &sem.SubqueryExpr{ |
| 1295 | Node: astExpr, |
| 1296 | Array: array, |
| 1297 | Correlated: correlated, |
| 1298 | Body: seq, |
| 1299 | } |
| 1300 | // Add a nullscan only for uncorrelated queries that don't have a source. |
| 1301 | if !correlated && !HasSource(e.Body) { |
| 1302 | e.Body.Prepend(&sem.NullScan{}) |
| 1303 | } |
| 1304 | if !array && t.scope.sql != nil { |
| 1305 | // SQL expects a record with a single column result so unravel this |
| 1306 | // condition with this complex cleanup... |
| 1307 | e.Body, outType = t.scalarSubqueryCheck(astExpr, e.Body, outType) |
| 1308 | } |
| 1309 | if array { |
| 1310 | outType = t.sctx.LookupTypeArray(outType) |
| 1311 | } |
| 1312 | return e, outType |
| 1313 | } |
| 1314 | |
| 1315 | func (t *translator) scalarSubqueryCheck(n ast.Node, seq sem.Seq, thisType super.Type) (sem.Seq, super.Type) { |
| 1316 | // In a SQL expression (except for RHS of EXISTS or IN, which both use array result), |
no test coverage detected