subgrounds
subgrounds copied to clipboard
How can one filter a column by condition NOT NULL
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.
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?
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
Glad you figured it out! I'll look towards adding a FAQ for this to try to help future devs.
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
They get defined as True or False statements, hence not valid.
@0xMochan created a PR for this (https://github.com/0xPlaygrounds/subgrounds/pull/53). I got the filter to work after all. Thanks for the help.
@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!