change(fastapi): unify all model relationship behavior

Now, we allow the direct relationships and their foreign keys to
be set in all of our models. Previously, we constrained this to
direct relationships, and this forced users to perform a query
in most situations to satisfy that requirement. Now, IDs can be
passed directly.

Additionally, this change removes the need for extraneous imports
when users which to use relationships. We now import and use models
directly instead of passing string-references to them.

Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
Kevin Morris 2021-10-16 16:16:44 -07:00
parent 0c37216626
commit 51320ab22a
No known key found for this signature in database
GPG key ID: F7E46DED420788F3
24 changed files with 181 additions and 297 deletions

View file

@ -11,8 +11,9 @@ class License(Base):
__mapper_args__ = {"primary_key": [ID]}
def __init__(self, Name: str = None):
self.Name = Name
def __init__(self, **kwargs):
super().__init__(**kwargs)
if not self.Name:
raise IntegrityError(
statement="Column Name cannot be null.",