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

How can one filter a column by condition NOT NULL #50

Open
gabrielfior opened this issue Mar 19, 2024 · 6 comments
Open

How can one filter a column by condition NOT NULL #50

gabrielfior opened this issue Mar 19, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@gabrielfior
Copy link
Contributor

Describe the bug
It's not clear from the documentation how one can filter the subgraph results by a column which should not be NULL.

To Reproduce
My (incorrect) query:

latest_markets = subgraph.Query.fixedProductMarketMakers(
        orderBy=subgraph.FixedProductMarketMaker.creationTimestamp,
        orderDirection="desc",
        first=2,
        where=[str(subgraph.FixedProductMarketMaker.resolutionTimestamp) != "null"], # problem here
    )

Expected behavior
I would expect an example to be found in the documentation.

@gabrielfior gabrielfior added the bug Something isn't working label Mar 19, 2024
@0xMochan
Copy link
Collaborator

Hey thanks for the report here, I'll def. add an example for this use-case to our docs. Do you mind sharing the specific subgraph here for context?

@gabrielfior
Copy link
Contributor Author

I actually figured out that one can write object.column is not None and use that as filter. So problem solved.

For reference, the subgraph is https://api.thegraph.com/subgraphs/name/protofire/omen-xdai/graphql

@0xMochan
Copy link
Collaborator

Glad you figured it out! I'll look towards adding a FAQ for this to try to help future devs.

@gabrielfior
Copy link
Contributor Author

gabrielfior commented Mar 21, 2024

Correction - the IS NOT NULL filter_condition I mentioned earlier does not work, see screenshot below

where_stms.append(fpmm.resolutionTimestamp is not None)

SUBGRAPH_URL = https://api.thegraph.com/subgraphs/name/protofire/omen-xdai/graphql

image

They get defined as True or False statements, hence not valid.

@gabrielfior
Copy link
Contributor Author

@0xMochan created a PR for this (#53). I got the filter to work after all.
Thanks for the help.

@0xMochan
Copy link
Collaborator

@0xMochan created a PR for this (#53). I got the filter to work after all. Thanks for the help.

Thanks so much for improving Subgrounds and creating a PR. I apologize for the delay in the response, but I'm looking to dive into this and quickly get it merged next week! Also, LMK if you had any issues with the CONTRIBUTING.md guide, I'm always looking for feedback to make it clearer and easier for newcomers to contribute!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants