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

Color Identity as filter not working #19

Open
timboudreau25 opened this issue Sep 27, 2018 · 1 comment
Open

Color Identity as filter not working #19

timboudreau25 opened this issue Sep 27, 2018 · 1 comment

Comments

@timboudreau25
Copy link

It appears the query ignores color identity filters. For example:

Card.where(power = 15).where(color_identity = 'G').all()

Returns four cards, only one of which has green (the other three are None). This happens even when the other cards are an actual color and not just colorless. When mixing and matching queries, the color identity is always ignored.

@Reid-E
Copy link
Contributor

Reid-E commented May 27, 2019

Each Resource class (Card, Set, Supertype, Type, Subtype, Changelog) passes the kwargs you give it to QueryBuilder, which uses those kwargs to make API calls. As a result, you need to use the API parameters and not the class fields for your kwards in Resource.where()

The API uses colorIdentity, not color_identity, because the API doesn't adhere to Python conventions.

You can test the query resulting from your Card.where() call by entering it into your browser at https://api.magicthegathering.io/v1/%r?%p1=v1&p2=v2...
%r is the resource name (plural) (ex. cards, sets)
%pn and %vn are the parameters and values (ex. power=15, colorIdentity='G')

Here's the API result of the query your function call would produce.

Try
Card.where(power=15, colorIdentity='G').all()

You can see the API result from your browser

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