You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Multiple logic files (as described in the docs/logic/readme.md) can result in duplicated logic in logic/logic_discovery, e.g.:
importdatetimefromdecimalimportDecimalfromlogic_bank.exec_row_logic.logic_rowimportLogicRowfromlogic_bank.extensions.rule_extensionsimportRuleExtensionfromlogic_bank.logic_bankimportRuleimportdatabase.modelsasmodelsimportapi.system.opt_locking.opt_lockingasopt_lockingfromsecurity.system.authorizationimportGrant, Securityimportlogginglogger=logging.getLogger(__name__)
defdeclare_logic():
''' Declarative multi-table derivations and constraints, extensible with Python. Brief background: see readme_declare_logic.md Your Code Goes Here - Use code completion (Rule.) to declare rules '''# this logic is automatically discovered by declare_logic.py#discover_logic()# Logic from GenAI: (or, use your IDE w/ code completion)fromdatabase.modelsimportProduct, Customer# Ensure customer names are not 'x'.Rule.constraint(validate=Customer,
as_condition=lambdarow: row.name.lower() !='x',
error_msg="Customer name cannot be 'x'")
# Ensure credit limits are non-negative.Rule.constraint(validate=Customer,
as_condition=lambdarow: row.credit_limit>=0,
error_msg="Credit limit cannot be negative")
# Ensure product names are not 'x'.Rule.constraint(validate=Product,
as_condition=lambdarow: row.name.lower() !='x',
error_msg="Product name cannot be 'x'")
# Ensure product prices are positive.Rule.constraint(validate=Product,
as_condition=lambdarow: row.unit_price>0,
error_msg="Product price must be positive")
# End Logic from GenAI# Logic from GenAI February 21, 2025 09:33:23:
The text was updated successfully, but these errors were encountered:
Multiple logic files (as described in the
docs/logic/readme.md
) can result in duplicated logic inlogic/logic_discovery
, e.g.:The text was updated successfully, but these errors were encountered: