Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"$having" missing from SoQL Parameters #53

Open
jwmueller85 opened this issue Feb 16, 2020 · 1 comment
Open

"$having" missing from SoQL Parameters #53

jwmueller85 opened this issue Feb 16, 2020 · 1 comment

Comments

@jwmueller85
Copy link

Hi Team,

Thank you for making this. I noticed I'm unable to write queries with the 'Having' Clause. The website documentation shows this method can use SQL having; however, the the code doesn't appear to call it out.

def get(self, dataset_identifier, content_type="json", **kwargs):
    '''
    Read data from the requested resource. Options for content_type are json,
    csv, and xml. Optionally, specify a keyword arg to filter results:

        select : the set of columns to be returned, defaults to *
        where : filters the rows to be returned, defaults to limit
        order : specifies the order of results
        group : column to group results on
        limit : max number of results to return, defaults to 1000
        offset : offset, used for paging. Defaults to 0
        q : performs a full text search for a value
        query : full SoQL query string, all as one parameter
        exclude_system_fields : defaults to true. If set to false, the
            response will include system fields (:id, :created_at, and
            :updated_at)

    More information about the SoQL parameters can be found at the official
    docs:
        http://dev.socrata.com/docs/queries.html

    More information about system fields can be found here:
        http://dev.socrata.com/docs/system-fields.html
    '''
    resource = _format_new_api_request(dataid=dataset_identifier, content_type=content_type)
    headers = _clear_empty_values({"Accept": kwargs.pop("format", None)})

    # SoQL parameters
    params = {
        "$select": kwargs.pop("select", None),
        "$where": kwargs.pop("where", None),
        "$order": kwargs.pop("order", None),
        "$group": kwargs.pop("group", None),
        "$limit": kwargs.pop("limit", None),
        "$offset": kwargs.pop("offset", None),
        "$q": kwargs.pop("q", None),
        "$query": kwargs.pop("query", None),
        "$$exclude_system_fields": kwargs.pop("exclude_system_fields",
                                              None)
    }

    # Additional parameters, such as field names
    params.update(kwargs)
    params = _clear_empty_values(params)

    response = self._perform_request("get", resource, headers=headers,
                                     params=params)
    return response
@rozap
Copy link
Contributor

rozap commented Apr 13, 2020

Hi, sorry for the late reply. Where's that code snippet from? Is that from the other library called soda-py?

They're different projects, and I definitely understand that confusion. It's something we've been talking about trying to straighten out. Soda-py has reading and metadata functionality in it. This library is pretty much only concerned with publishing data to socrata, so socrata-py is probably not the best name for it...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants