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 shortcut for alias in specs #41

Closed
wants to merge 2 commits into from
Closed

Add shortcut for alias in specs #41

wants to merge 2 commits into from

Conversation

j4mie
Copy link
Member

@j4mie j4mie commented Jul 9, 2021

This introduces a new bit of syntax into a spec, providing a shortcut to alias the output of a projector. This brings things a little closer to the syntax used by SSM plugins, where the output key name is clearly visible in the spec.

This allows you to do things like this:

def project_full_name(instance):
    return {"full_name": f"{instance.first_name} {instance.last_name}"}

full_name = (qs.include_fields("first_name", "last_name"), project_full_name)

spec = [
    "name",
    {"whole_entire_name": full_name},
    {"age_in_years": "years_since_birth"},
]

@j4mie j4mie changed the title Add shortcuts for alias in specs Add shortcut for alias in specs Jul 14, 2021
Copy link
Contributor

@pmg103 pmg103 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something odd about needing to specify the key even though you intend to alias it but this is a sensible PR on its own terms

@j4mie
Copy link
Member Author

j4mie commented Jul 16, 2021

Superseded by #43

@j4mie j4mie closed this Jul 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

Successfully merging this pull request may close these issues.

2 participants