SQL._parse_filter refactored