I am getting an inconsistent reverse attributes exception from my PonyORM model definitions. I have spent 90 minutes reading other SO issues and the docs but can't figure out how to resolve this.
code:
from datetime import date, datetime
from pony import orm
db = orm.Database()
class Milestone(db.Entity):
cat = orm.Required(str)
subcat = orm.Required(str)
orm.PrimaryKey(cat, subcat)
planned = orm.Optional('DateSet', reverse='milestone')
actual = orm.Optional('DateSet', reverse='milestone')
class DateSet(db.Entity):
start = orm.Optional(date)
end = orm.Optional(date)
workingdays = orm.Optional(int)
created = orm.Required(datetime, sql_default='CURRENT_TIMESTAMP')
milestone = orm.Optional(Milestone)
db.bind(provider='sqlite', filename='local.db', create_db=True)
orm.set_sql_debug(True)
db.generate_mapping(create_tables=True)
The above can be executed directly to produce the error below.
exception:
pony.orm.core.ERDiagramError: Inconsistent reverse attributes Milestone.actual and DateSet.milestone
Is there an option not to have a reverse mapping? I don't need it and I'd rather not have it. In my case the DateSet entity will be used in many places (not just Milestones) so I'd actually prefer not to have that attribute on the entity at all, and just have a one-way relationship.
Put differently, imagine I have an entity AnnotatedDateRange which contains start: date, end: date, note: str -- I might use AnnotatedDateRange as follows:
Foo.period1: AnnotatedDateRange
Foo.period2: AnnotatedDateRange
Bar.duration: AnnotatedDateRange
Wibble.calendarhold: AnnotatedDateRange
So just because Foo, Bar, and Wibble all have attributes which reference instances of entity type AnnotatedDateRange does not mean that I want every instance of AnnotatedDateRange to have some mechanism to refer back to the referring entity.