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

add Query.one_field_name and get_field_name #112

Closed
Jaymon opened this issue Jun 30, 2020 · 2 comments
Closed

add Query.one_field_name and get_field_name #112

Jaymon opened this issue Jun 30, 2020 · 2 comments

Comments

@Jaymon
Copy link
Owner

Jaymon commented Jun 30, 2020

So we currently have get_pk() that acts as an alias for Query.is_pk(pk).one() but we should generic that, so you can do it for any field, the get_* version would return an iterator, and the one_* version would return the first match

@Jaymon
Copy link
Owner Author

Jaymon commented Oct 13, 2021

Another approach would be to have get_<FIELDNAME> check the <FIELDNAME> against all the aliases and if it gets it then it would run one() against that field name.

If it didn't find it would check if the last character was an s, if it is it would strip it and do the check again, but use in_<FIELDNAME> to build the query instead.

If the endswith("s") check failed then it would try endswith("es") and do the same as above.

@Jaymon
Copy link
Owner Author

Jaymon commented Oct 13, 2021

value_* and values_* can also be added to this list

@Jaymon Jaymon closed this as completed in 5ea49a2 Oct 16, 2021
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

1 participant