ApiLogicServer / ApiLogicServer-src

Create an executable project (API and Admin App) from a database or natural language prompt with 1 command, customize with declarative rules and Python in your IDE, containerize and deploy.
https://apilogicserver.github.io/Docs/
BSD 3-Clause "New" or "Revised" License
28 stars 4 forks source link

Feature Request: RowDictMapper should address Join fields #45

Closed valhuber closed 7 months ago

valhuber commented 7 months ago

The current implementation provides only for (aliased) row attributes, but not join attributes.

For example:

class TransferMapper(RowDictMapper):
    """ Format

    Map Transfer row into dict for sending as Kafka message

    Returns:
        _type_: RowDictMapper object
    """

    def __init__(self, logic_row: LogicRow = None):
        """ Format

        Map Transfer row into dict for sending as Kafka message

        Note: declare Customer.FirstName (a join field)

        Returns:
            _type_: RowDictMapper object
        """
        transfer = super(TransferMapper, self).__init__(
            model_class=models.Transfer
            , logic_row=logic_row
            , alias = "transfer"
            , fields = [ (logic_row.row.Account.Customer.FirstName, "First"),
                        (logic_row.row.Account.Customer.LastName, "Last"),
                        models.Transfer.FromAccountID, models.Transfer.ToAccountID,
                        models.Transfer.TransactionDate, models.Transfer.Amount
                    ]
            )
        return transfer
valhuber commented 7 months ago

Solution requires breaking change to RowDictMaps:

from logic_bank.exec_row_logic.logic_row import LogicRow

class OrderShipping(RowDictMapper):

    def __init__(self, logic_row: LogicRow = None):
valhuber commented 7 months ago

Fixed in 10.03.04