Fixed #21554 -- Incorrect SQL generated when using multiple inheritance.