Fix relationship query