kapps_ogm.mapping.property_spec#

class kapps_ogm.mapping.property_spec.PropertyValueKind(*values)[source]#

Bases: Enum

LITERAL = 'literal'#
OBJECT = 'object'#
COMPLEX = 'complex'#
kapps_ogm.mapping.property_spec.chain_ranges(prop_iri: IRI, range_var: str, ancestor_var: str = '?ancestor') → str[source]#

The SPARQL prelude binding range_var to every rdfs:range along a property’s chain.

RDFS entails no rdfs:range triple for a subproperty and GraphDB materializes none, so every query that needs a property’s effective shape has to walk the chain itself. The * path is a transitive closure, which is what makes a cyclic rdfs:subPropertyOf assertion terminate rather than recurse. Shared so the four call sites cannot drift.

class kapps_ogm.mapping.property_spec.PropertySpec(iri: 'IRI', value_kind: 'PropertyValueKind', python_range_type: 'Optional[Type]' = None, min_count: 'Optional[int]' = None, max_count: 'Optional[int]' = None, some_from: 'Optional[Union[IRI, Type]]' = None, all_from: 'Optional[Union[IRI, Type]]' = None, nested: "Optional['ClassSpec']" = None)[source]#

Bases: object

iri: IRI#
value_kind: PropertyValueKind#
python_range_type: Type | None = None#
min_count: int | None = None#
max_count: int | None = None#
some_from: IRI | Type | None = None#
all_from: IRI | Type | None = None#
nested: 'ClassSpec' | None = None#
property required: bool#
property restriction_target: IRI | Type | None#

The datatype or class this restriction constrains values to.

None for a cardinality-only restriction, which says nothing about the value’s type and so cannot conflict with one that does. python_range_type and all_from are mutually exclusive as built by _specify_complex_property — one holds a resolved datatype, the other a class IRI — so the order below only decides which a hand-built spec reports.

to_string() → str[source]#
to_pydantic_field() → tuple[Any, Any][source]#

Convert this PropertySpec into a Pydantic field with validators.

merge_conjunctive(other: PropertySpec, owner_iri: IRI) → PropertySpec[source]#

Conjunctive merge of two restrictions on the same nested property.

Returns a new PropertySpec; does not mutate either input. owner_iri appears in error messages so a failure names the property whose range is malformed.

classmethod specify(prop_iri: IRI, nested_scope: 'ClassScope' | None, ogm: OGM, hydration_level: ClassHydrationLevel) → PropertySpec[source]#