fix query for index expressions on older databases