mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
add PackageRelation SQLAlchemy ORM model
Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
a9cfbce11e
commit
2b83d2fb6b
2 changed files with 133 additions and 0 deletions
33
aurweb/models/package_relation.py
Normal file
33
aurweb/models/package_relation.py
Normal file
|
@ -0,0 +1,33 @@
|
|||
from sqlalchemy.orm import mapper
|
||||
|
||||
from aurweb.db import make_relationship
|
||||
from aurweb.models.package import Package
|
||||
from aurweb.models.relation_type import RelationType
|
||||
from aurweb.schema import PackageRelations
|
||||
|
||||
|
||||
class PackageRelation:
|
||||
def __init__(self, Package: Package = None,
|
||||
RelationType: RelationType = None,
|
||||
RelName: str = None, RelCondition: str = None,
|
||||
RelArch: str = None):
|
||||
self.Package = Package
|
||||
self.RelationType = RelationType
|
||||
self.RelName = RelName # nullable=False
|
||||
self.RelCondition = RelCondition
|
||||
self.RelArch = RelArch
|
||||
|
||||
|
||||
properties = {
|
||||
"Package": make_relationship(Package, PackageRelations.c.PackageID,
|
||||
"package_relations"),
|
||||
"RelationType": make_relationship(RelationType,
|
||||
PackageRelations.c.RelTypeID,
|
||||
"package_relations")
|
||||
}
|
||||
|
||||
mapper(PackageRelation, PackageRelations, properties=properties,
|
||||
primary_key=[
|
||||
PackageRelations.c.PackageID,
|
||||
PackageRelations.c.RelTypeID
|
||||
])
|
Loading…
Add table
Add a link
Reference in a new issue