#226 Fix SQLAlchemy warning
Opened 5 months ago by misc. Modified 5 months ago

Fix SQLAlchemy warning
Michael Scherer • 5 months ago  
file modified
+2 -2
@@ -141,7 +141,7 @@ 

          ForeignKey('calendar_status.status', onupdate="cascade"),

          default='Enabled',

          nullable=False)

-     meetings = relationship("Meeting")

+     meetings = relationship("Meeting", back_populates="calendar")

  

      def __init__(

              self, calendar_name, calendar_contact, calendar_description,
@@ -336,7 +336,7 @@ 

          String(80),

          ForeignKey('calendars.calendar_name', onupdate="cascade"),

          nullable=False)

-     calendar = relationship("Calendar", lazy='joined')

+     calendar = relationship("Calendar", lazy='joined', back_populates="meetings")

      # 5 person max (32 * 5) + 5 = 165

      meeting_manager_user = relationship('MeetingsUsers', lazy='joined')

      meeting_date = Column(Date, default=safunc.now(), nullable=False)

Since Calendar and Meeting class reference each others, we have to be
explicit on the way the library must deal with conflicts. In this
case, the solution is to update the other object when there is a change.

It should partially fix #223

Metadata