Skip to content

Commit

Permalink
updates for pre-release v0.0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
timothygraefe committed Nov 2, 2021
1 parent 82d0e9e commit 3233868
Show file tree
Hide file tree
Showing 13 changed files with 122 additions and 1,087 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,6 @@ class ModelB(models.Model):
# and each edge will be in different graphs.
modela = EdgeField('ModelA', graph_name='ABTest')
```

# Design Notes
Additional information about design and the edge field implementation is in fields.md
2 changes: 1 addition & 1 deletion djarango/db/backends/arangodb/base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# base.py
#
# Timothy Graefe, Javamata LLC
# Timothy Graefe, Javamata LLC, Nov 2021
#

import logging
Expand Down
3 changes: 2 additions & 1 deletion djarango/db/backends/arangodb/client.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#
# client.py
#
# Timothy Graefe, Javamata LLC
# Timothy Graefe, Javamata LLC, Nov 2021
#

import logging
Expand Down
2 changes: 1 addition & 1 deletion djarango/db/backends/arangodb/compiler.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# compiler.py
#
# Timothy Graefe, Javamata LLC
# Timothy Graefe, Javamata LLC, Nov 2021
#

import logging
Expand Down
2 changes: 2 additions & 0 deletions djarango/db/backends/arangodb/creation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#
# creation.py
#
# Timothy Graefe, Javamata LLC, Nov 2021
#
from django.db.backends.base.creation import BaseDatabaseCreation

# Needed to link into backend options.
Expand Down
6 changes: 6 additions & 0 deletions djarango/db/backends/arangodb/features.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
#
# features.py
#
# Timothy Graefe, Javamata LLC, Nov 2021
#

from django.db.backends.base.features import BaseDatabaseFeatures

class DatabaseFeatures(BaseDatabaseFeatures):
Expand Down
12 changes: 12 additions & 0 deletions djarango/db/backends/arangodb/fields/edge_descriptors.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
#
# edge_descriptors.py
#
# Timothy Graefe, Javamata LLC, Nov 2021
#

# Reference note; copied from django/db/models/fields/related_descriptors.py and
# updated with my implementation notes.
"""
Accessors for related edge objects (copied from related_descriptors.py)
Expand All @@ -21,6 +29,7 @@ class Child(Model):
``child.parent`` is a forward many-to-one relation. ``parent.children`` is a
reverse many-to-one relation.
TTG
Edge descriptors:
Edge descriptors are most like many-to-many forward descriptors. In Djarango,
Expand All @@ -31,9 +40,11 @@ class Child(Model):
be distinct from each other.
related_descriptors.py:
There are three types of relations (many-to-one, one-to-one, and many-to-many)
and two directions (forward and reverse) for a total of six combinations.
TTG
But with Edges, all relations are m2m and forward.
related_descriptors.py:
Expand All @@ -50,6 +61,7 @@ class Child(Model):
"""

# Implementation - copied from related_descriptors.py and adapted.
from django.core.exceptions import FieldError
from django.db import connections, router, transaction
from django.db.models import Q, signals
Expand Down
8 changes: 0 additions & 8 deletions djarango/db/backends/arangodb/fields/edges.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ class EdgeRel(ForeignObjectRel):
"""

def __init__(self, field, to, graph_name=None, edge_name=None):
#breakpoint()

# super().__init__() resolves to ForeignObjectRel constructor.
# Nothing significant, other than setting field and model attributes.
super().__init__(field, to)
Expand Down Expand Up @@ -179,9 +177,6 @@ class EdgeField(RelatedField):

def __init__(self, to, graph_name=None, edge_name=None,
swappable=True, **kwargs):

#breakpoint()

# During __init__, 'to' must be a class or a string. If it is a string,
# the 'try' block below will fail with 'AttributeError'. This is fine
# as long as the parameter is a string.
Expand Down Expand Up @@ -229,7 +224,6 @@ def __init__(self, to, graph_name=None, edge_name=None,
# It invokes contribute_to_class in this file when adding EdgeField.

def check(self, **kwargs):
#breakpoint()
return [
*super().check(**kwargs),
*self._check_unique(**kwargs),
Expand All @@ -253,7 +247,6 @@ def contribute_to_class(self, cls, name, **kwargs):
# name - name of the class member, e.g., 'modelb'

# TTG: symmetrical should not be supported for EdgeField
#breakpoint()
assert self.remote_field.symmetrical is False, ("Edge models cannot be symmetric")
assert self.remote_field.is_hidden() is False, ("Edge models cannot hide remote fields")

Expand Down Expand Up @@ -313,7 +306,6 @@ def deconstruct(self):
self.assertEqual(my_field_instance.some_attribute,
new_field_instance.some_attribute)
"""
#breakpoint()
name, path, args, kwargs = super().deconstruct()

# There is only 1 positional arguments: target model (e.g., 'ModelB')
Expand Down
Loading

0 comments on commit 3233868

Please sign in to comment.