From d2e764f3888cac2ab65d1a88ce0b418fd8b2bf60 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Tue, 23 Jul 2019 10:55:42 -0500 Subject: [PATCH] Rename attributes for MemberType data model also, comment-out the "sales code" column for now, since it doesn't exist in all production databases. (not sure how best to handle that yet) --- corepos/db/model.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/corepos/db/model.py b/corepos/db/model.py index 02aa313..318ea45 100644 --- a/corepos/db/model.py +++ b/corepos/db/model.py @@ -332,11 +332,11 @@ class MemberType(Base): """ __tablename__ = 'memtype' - memtype = sa.Column(sa.SmallInteger(), primary_key=True, nullable=False, default=0) + id = sa.Column('memtype', sa.SmallInteger(), primary_key=True, nullable=False, default=0) - memDesc = sa.Column(sa.String(length=20), nullable=True) + description = sa.Column('memDesc', sa.String(length=20), nullable=True) - custdataType = sa.Column(sa.String(length=10), nullable=True) + customer_type = sa.Column('custdataType', sa.String(length=10), nullable=True) discount = sa.Column(sa.SmallInteger(), nullable=True) @@ -344,10 +344,12 @@ class MemberType(Base): ssi = sa.Column(sa.Boolean(), nullable=True) - salesCode = sa.Column(sa.Integer(), nullable=True) + # TODO: this was apparently added "recently" - isn't present in all DBs + # (need to figure out how to conditionally include it in model?) + # sales_code = sa.Column('salesCode', sa.Integer(), nullable=True) def __str__(self): - return self.memDesc or "" + return self.description or "" class Customer(Base): @@ -404,7 +406,7 @@ class Customer(Base): member_type = orm.relationship( MemberType, - primaryjoin=MemberType.memtype == memType, + primaryjoin=MemberType.id == memType, foreign_keys=[memType], doc=""" Reference to the :class:`MemberType` to which this member belongs.