public static function buildFieldQuery($config, $idProperty)
    {
        if ($config->getIdOnly()) {
            return $idProperty;
        }
        if (null !== $config->getFields()) {
            $fields = \implode(', ', $config->getFields());
            if (false !== \stripos($fields, 'DISTINCT')) {
                return $fields;
            }
            return $idProperty . ', ' . $fields;
        }

        return '*';
    }