Use type to hint that constraining to embedded fields is a good first step

This improves the join order for `implicitFieldSelection`
This commit is contained in:
Chris Smowton
2021-03-15 11:59:36 +00:00
committed by Owen Mansel-Chan
parent e1b4867a19
commit 22a3fccf79

View File

@@ -48,11 +48,15 @@ private predicate isCond(Expr e) {
e = any(ParenExpr par | isCond(par)).getExpr()
}
private class PromotedField extends Field {
PromotedField() { this = any(StructType t).getFieldOfEmbedded(_, _, _, _) }
}
private predicate implicitFieldSelection(SelectorExpr e, int i, Field implicitField) {
exists(StructType baseType, Field child |
exists(StructType baseType, PromotedField child |
baseType = e.getBase().getType().getBaseType*().getUnderlyingType() and
(
e.getSelector() = child.getAReference()
e.refersTo(child)
or
implicitFieldSelection(e, i + 1, child)
)