Adjust VersionedWhereNode as_sql logic
Adjust VersionedWhereNode as_sql logic

This allows the SelfReferencingManyToManyTest.test_relationship_spanning_query
test to pass; it was previously raising an error.

swisscom/cleanerversion,swisscom/cleanerversion,swisscom/cleanerversion