Skip to content

Commit

Permalink
Schema.repr_entity() to turn an entity type into an alias
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeboers committed Jan 26, 2016
1 parent 89c82d8 commit e5544ba
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions sgschema/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,12 @@ def resolve_one_entity(self, entity_spec, **kwargs):
else:
raise ValueError('%r returned %s entity types' % (entity_spec, len(res)))

def repr_entity(self, entity_type):
for alias, type_ in sorted(self.entity_aliases.iteritems()):
if type_ == entity_type:
return '$' + alias
return entity_type

def _resolve_field(self, entity_spec, field_spec, auto_prefix=True, implicit_aliases=True, strict=False):

try:
Expand Down

0 comments on commit e5544ba

Please sign in to comment.