potassco / clorm

🗃️ A Python ORM-like interface for the Clingo Answer Set Programming (ASP) reasoner
https://clorm.readthedocs.io
MIT License
52 stars 5 forks source link

Bugfix: Enum was ignored when used in combination with ConstantStr #105

Closed florianfischer91 closed 2 years ago

florianfischer91 commented 2 years ago

Let's consider the following situation

class Status(ConstantStr, enum.Enum):
    ON  = "on"
    OFF = "off"

 class Robot(Predicate):
     name: str
     status: Status

Because of a wrong priority (order) when trying to infer (create) the correct Field, Robot.status was handled as a ConstantField instead of a custom Field which restricts the allowed values. The result was that you could create a Robot-fact with status f.i. "standby"

This PR fixes that problem by first handling the case if the type of Status is an Enum and handle the case for a ConstantStr afterwards