The correct way to do this is to define a ToSql() method on IJoinExpression and use polymorphism here, but that wasn't working right before anyway.