diff --git a/README.rst b/README.rst index 86e3f59..83721fb 100644 --- a/README.rst +++ b/README.rst @@ -119,3 +119,9 @@ additional parameters 0.9.0 - Add logicRow.get_derived_attributes, which can be used to enforce behaviors such as `Unalterable Derivations `_ + +0.9.2 - Add session to logic_row.__str__(), listeners + +0.9.3 - Allow for nulls in summed/sum + +0.9.4 - Fix bad Warning: Missing Parent: diff --git a/logic_bank/exec_row_logic/logic_row.py b/logic_bank/exec_row_logic/logic_row.py index 8355ddd..9061793 100644 --- a/logic_bank/exec_row_logic/logic_row.py +++ b/logic_bank/exec_row_logic/logic_row.py @@ -147,8 +147,8 @@ def __str__(self): result += value else: result += str(value) - result += f' row@: {str(hex(id(self.row)))}' - result += f' session@: {str(hex(id(self.session)))}' + result += f' row: {str(hex(id(self.row)))}' + result += f' session: {str(hex(id(self.session)))}' return result # str(my_dict) def log(self, msg: str) -> str: @@ -665,10 +665,12 @@ def load_parents_on_insert(self): if each_relationship.direction == sqlalchemy.orm.interfaces.MANYTOONE: # cust, emp parent_role_name = each_relationship.key # eg, OrderList if self.is_foreign_key_null(each_relationship) is False: - # continue + # continue - foreign key not null - parent *should* exist self.get_parent_logic_row(parent_role_name) # sets the accessor does_parent_exist = getattr(self.row, parent_role_name) - if does_parent_exist is None and ref_integ_enabled: + if does_parent_exist: + pass # yes, parent exists... it's all fine + elif ref_integ_enabled: msg = "Missing Parent: " + parent_role_name self.log(msg) ll = RuleBank() diff --git a/logic_bank/exec_trans_logic/listeners.py b/logic_bank/exec_trans_logic/listeners.py index 58f8f33..a204daa 100644 --- a/logic_bank/exec_trans_logic/listeners.py +++ b/logic_bank/exec_trans_logic/listeners.py @@ -13,7 +13,7 @@ def before_commit(a_session: session): * not called for auto-commit transactions * called prior to before_flush """ - logic_bank.logic_logger.debug("\nLogic Phase:\t\tBEFORE COMMIT \t\t\t\t\t\t") + logic_bank.logic_logger.debug(f'\nLogic Phase:\t\tBEFORE COMMIT(session={str(hex(id(a_session)))}) \t\t\t\t\t\t') def before_flush(a_session: session, a_flush_context, an_instances): @@ -29,7 +29,7 @@ def before_flush(a_session: session, a_flush_context, an_instances): """ Logic Phase """ - logic_bank.logic_logger.debug("Logic Phase:\t\tROW LOGIC (sqlalchemy before_flush)\t\t\t") + logic_bank.logic_logger.debug(f'Logic Phase:\t\tROW LOGIC(session={str(hex(id(a_session)))}) (sqlalchemy before_flush)\t\t\t') row_sets = RowSets() # type : RowSet client_inserts = [] @@ -71,7 +71,7 @@ def before_flush(a_session: session, a_flush_context, an_instances): """ Commit Logic Phase """ - logic_bank.logic_logger.debug("Logic Phase:\t\tCOMMIT \t\t\t\t\t\t\t\t\t") + logic_bank.logic_logger.debug(f'Logic Phase:\t\tCOMMIT(session={str(hex(id(a_session)))}) \t\t\t\t\t\t\t\t\t\t') processed_rows = dict.copy(row_sets.processed_rows) # set in LogicRow ctor for each_logic_row_key in processed_rows: each_logic_row = processed_rows[each_logic_row_key] @@ -84,7 +84,7 @@ def before_flush(a_session: session, a_flush_context, an_instances): """ Proceed with sqlalchemy flush processing """ - logic_bank.logic_logger.debug("Logic Phase:\t\tFLUSH (sqlalchemy flush processing \t") + logic_bank.logic_logger.debug(f'Logic Phase:\t\tFLUSH(session={str(hex(id(a_session)))}) (sqlalchemy flush processing) \t') def temp_debug(a_session, bug_explore, row_cache): diff --git a/logic_bank/extensions/copy_row.py b/logic_bank/extensions/copy_row.py index ec21713..cf8a90f 100644 --- a/logic_bank/extensions/copy_row.py +++ b/logic_bank/extensions/copy_row.py @@ -43,6 +43,9 @@ def execute(self, logic_row: LogicRow): copy_to_logic_row = copy_from.new_logic_row(new_row_class=self.copy_to) copy_to_logic_row.link(to_parent=copy_from) copy_to_logic_row.set_same_named_attributes(copy_from) + do_session_add = False + if do_session_add: # does not appear to matter... + copy_to_logic_row.session.add(copy_to_logic_row.row) copy_to_logic_row.insert(reason="Copy " + copy_to_logic_row.name) # triggers rules... # copy_from.log(f'END {str(self)}') return self diff --git a/logic_bank/rule_type/aggregate.py b/logic_bank/rule_type/aggregate.py index 03c1237..b11f558 100644 --- a/logic_bank/rule_type/aggregate.py +++ b/logic_bank/rule_type/aggregate.py @@ -74,6 +74,8 @@ def adjust_from_inserted_child(self, curr_value = getattr(parent_adjustor.parent_logic_row.row, self._column) if curr_value is None: curr_value = 0 + if delta is None: + delta = 0 setattr(parent_adjustor.parent_logic_row.row, self._column, curr_value + delta) # parent_adjustor.child_logic_row.log(f'adjust_from_inserted/adopted_child adjusts {str(self)}') diff --git a/setup.py b/setup.py index 59d3a9c..92d2a4c 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ def desc(): setup( name="logicbank", - version="0.9.0", + version="0.9.4", url="https://github.com/valhuber/logicbank", license="BSD", author="Val Huber",