mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
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>
21 lines
527 B
Python
21 lines
527 B
Python
from sqlalchemy import Column, Integer
|
|
from sqlalchemy.exc import IntegrityError
|
|
|
|
from aurweb.models.declarative import Base
|
|
|
|
|
|
class License(Base):
|
|
__tablename__ = "Licenses"
|
|
|
|
ID = Column(Integer, primary_key=True)
|
|
|
|
__mapper_args__ = {"primary_key": [ID]}
|
|
|
|
def __init__(self, **kwargs):
|
|
super().__init__(**kwargs)
|
|
|
|
if not self.Name:
|
|
raise IntegrityError(
|
|
statement="Column Name cannot be null.",
|
|
orig="Licenses.Name",
|
|
params=("NULL"))
|