From 29638c062c6c1df8e7d9fc4a0e61b6389036e548 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Mon, 7 Dec 2020 17:41:01 -0600 Subject: [PATCH] Remove "default" values from Product model definition i'm a bit torn about this. on the one hand i like there being some default values here, but realistically they didn't all make sense. also it could be said that default values amount to business logic and that should stay in CORE basically. but in the end, i needed these to go away in order to simplify generating some SQL INSERT statements. was using SQLAlchemy core and it kept insisting that all fields with a "default" defined should be part of the INSERT statement, but really i didn't want them to be. so they no longer have defaults. --- corepos/db/office_op/model.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/corepos/db/office_op/model.py b/corepos/db/office_op/model.py index 24a185e..6799fbe 100644 --- a/corepos/db/office_op/model.py +++ b/corepos/db/office_op/model.py @@ -481,7 +481,10 @@ class Product(Base): scale = sa.Column(sa.Boolean(), nullable=True) - scale_price = sa.Column('scaleprice', sa.Boolean(), nullable=True, default=False) + # TODO: yikes, did i just code this all wrong the first time? pretty sure + # this needs to change to a decimal column... + scale_price = sa.Column('scaleprice', sa.Boolean(), nullable=True) + # scale_price = sa.Column('scaleprice', sa.Numeric(precision=10, scale=2), nullable=True) mix_match_code = sa.Column('mixmatchcode', sa.String(length=13), nullable=True) @@ -505,11 +508,11 @@ class Product(Base): id_enforced = sa.Column('idEnforced', sa.SmallInteger(), nullable=True) - cost = sa.Column(sa.Float(), nullable=True, default=0) + cost = sa.Column(sa.Float(), nullable=True) in_use = sa.Column('inUse', sa.Boolean(), nullable=True) - flags = sa.Column('numflag', sa.Integer(), nullable=True, default=0) + flags = sa.Column('numflag', sa.Integer(), nullable=True) subdepartment_number = sa.Column('subdept', sa.SmallInteger(), nullable=True) subdepartment = orm.relationship( @@ -522,11 +525,11 @@ class Product(Base): deposit = sa.Column(sa.Float(), nullable=True) - local = sa.Column(sa.Integer(), nullable=True, default=0) + local = sa.Column(sa.Integer(), nullable=True) - store_id = sa.Column(sa.SmallInteger(), nullable=True, default=0) + store_id = sa.Column(sa.SmallInteger(), nullable=True) - default_vendor_id = sa.Column(sa.Integer(), nullable=True, default=0) + default_vendor_id = sa.Column(sa.Integer(), nullable=True) default_vendor = orm.relationship( Vendor, primaryjoin=Vendor.id == default_vendor_id, @@ -537,7 +540,7 @@ class Product(Base): # TODO: deprecate / remove this? vendor = orm.synonym('default_vendor') - current_origin_id = sa.Column(sa.Integer(), nullable=True, default=0) + current_origin_id = sa.Column(sa.Integer(), nullable=True) # TODO: some older DB's might not have this? guess we'll see last_sold = sa.Column(sa.DateTime(), nullable=True)