-
Notifications
You must be signed in to change notification settings - Fork 48
Add backlinks to query builder #961
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
Conversation
7afa03c to
a6ec0a5
Compare
|
This seems basically plausible; could you post some of the generated model code here? |
10139fb to
a98a638
Compare
e4582d6 to
6c2ed38
Compare
4a20778 to
3d482e1
Compare
|
In All other backlinks classes derive from class __BaseObject_backlinks__(GelObjectBacklinksModel):
class __gel_reflection__(GelObjectBacklinksModel.__gel_reflection__):
name = SchemaPath.from_segments('std', 'BaseObject')
type_name = SchemaPath.from_segments('std', 'BaseObject')
@LazyClassProperty["dict[builtins.str, GelPointerReflection]"]
@classmethod
def pointers(cls,) -> dict[builtins.str, GelPointerReflection]:
my_ptrs: dict[builtins.str, GelPointerReflection] = {}
return my_ptrsWhich is added to class BaseObject(...):
...
__backlinks__: GelObjectBacklinksModelDescriptor[__BaseObject_backlinks__] = GelObjectBacklinksModelDescriptor[__BaseObject_backlinks__]()
...For user defined types, an object class __Inh_A_backlinks__(std_shapes.__Object_backlinks__):
class __gel_reflection__(
std_shapes.__Object_backlinks__.__gel_reflection__
):
name = SchemaPath.from_segments('default', 'Inh_A')
type_name = SchemaPath.from_segments('default', 'Inh_A')
@LazyClassProperty["dict[str, GelPointerReflection]"]
@classmethod
def pointers(cls,) -> dict[str, GelPointerReflection]:
my_ptrs: dict[str, GelPointerReflection] = {
'l': GelPointerReflection(
name='l',
type=std_shapes.BaseObject,
kind=PointerKind('Link'),
cardinality=Cardinality('Many'),
computed=True,
readonly=True,
has_default=False,
mutable=False,
properties=None,
),
}
return (
my_ptrs
| std_shapes.__Object_backlinks__.__gel_reflection__.pointers
)
l: ComputedMultiLink[std_shapes.BaseObject]
...
class Inh_A(...):
__backlinks__: GelObjectBacklinksModelDescriptor[__Inh_A_backlinks__] = GelObjectBacklinksModelDescriptor[__Inh_A_backlinks__]()
... |
msullivan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!
| base_backlinks_reflections: list[str] | ||
| base_backlinks_models: list[str] | ||
|
|
||
| if objtype.name == "std::BaseObject": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment on why this is special?
|
|
||
| backlinks_model_name = self._mangle_backlinks_model_name(name) | ||
|
|
||
| base_object_types = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a name change here or a comment, but there is a bunch of code here dealing with both the base types of the current object and also BaseObject, and it's a little confusing
Object models now have a
__backlinks__field, which is set to aGelObjectBacklinksModel. This backlinks model contains multi links tostd::BaseObject.These new backlinks models are generated during reflection. At runtime, intersections generate a backlink model alongside the intersection type.
A simple query with backlinks:
A more complex query with backlinks:
Also works inside shapes: