|
26 | 26 | )
|
27 | 27 |
|
28 | 28 |
|
| 29 | +ILLEGAL_PROPERTY_NAMES = ( |
| 30 | + # Names we reserve for referencing base connections as fields of an IndexDefinition object. |
| 31 | + 'out', |
| 32 | + 'in', |
| 33 | +) |
| 34 | + |
| 35 | + |
29 | 36 | class SchemaGraph(object):
|
30 | 37 | """The SchemaGraph is a graph utility used to represent a OrientDB schema.
|
31 | 38 |
|
@@ -419,7 +426,12 @@ def _validate_non_abstract_edge_has_defined_base_connections(
|
419 | 426 | def _validate_property_names(class_name, properties):
|
420 | 427 | """Validate that properties do not have names that may cause problems in the GraphQL schema."""
|
421 | 428 | for property_name in properties:
|
422 |
| - if not property_name or property_name.startswith(ILLEGAL_PROPERTY_NAME_PREFIXES): |
| 429 | + is_illegal_name = ( |
| 430 | + not property_name or |
| 431 | + property_name.startswith(ILLEGAL_PROPERTY_NAME_PREFIXES) or |
| 432 | + property_name in ILLEGAL_PROPERTY_NAMES |
| 433 | + ) |
| 434 | + if is_illegal_name: |
423 | 435 | raise IllegalSchemaStateError(u'Class "{}" has a property with an illegal name: '
|
424 | 436 | u'{}'.format(class_name, property_name))
|
425 | 437 |
|
@@ -583,7 +595,9 @@ def link_schema_elements(elements, inheritance_structure):
|
583 | 595 | # A way to describe an index:
|
584 | 596 | # - name: string, the name of the index.
|
585 | 597 | # - base_classname: string, the name of the class on which the index is defined.
|
586 |
| -# - fields: set of strings, the set of fields which the index encompasses. |
| 598 | +# - fields: set of strings, indicating which objects the index encompasses. |
| 599 | +# The 'in' and 'out' strings refer to the base connections. |
| 600 | +# All other strings reference the base class's properties. |
587 | 601 | # - unique: bool, indicating whether this index is unique.
|
588 | 602 | # - ordered: bool, indicating whether this index is ordered.
|
589 | 603 | # - ignore_nulls: bool, indicating if the index ignores null values.
|
|
0 commit comments