Note that there are some explanatory texts on larger screens.

plurals
  1. POUpdate SQLAlchemy relationship
    text
    copied!<p>I have two relationships to the same table. When I add an element to one relationship, this does not reflect to the other relationship until I submit the session. Is there a way to force "update" the relationships?</p> <p><strong>Concrete example:</strong></p> <pre><code>class Event(ManagerBase): """Defines an event.""" __tablename__ = 'eventing_events' id = Column(Integer, primary_key=True) device_id = Column(Integer, ForeignKey(EventingDevice.id), nullable=False) device = relation(EventingDevice) type_id = Column(Integer, ForeignKey(EventType.id), nullable=False) type = relation(EventType) datetime = Column(DateTime, nullable=False) summary = Column(String(500)) fields = relation("EventFieldValue", viewonly=True, collection_class=attribute_mapped_collection("field.name")) class EventFieldValue(ManagerBase): """The value of a single field of an event.""" __tablename__ = 'eventing_event_field_values' event_id = Column(Integer, ForeignKey(Event.id), primary_key=True) event = relation(Event, backref=backref("field_values", collection_class=attribute_mapped_collection("field"))) field_id = Column(Integer, ForeignKey(Field.id), primary_key=True) field = relation(Field) value = Column(Text) </code></pre> <p>I have two realations from <code>Event</code> to <code>EventFieldValue</code>: <code>fields</code> and <code>field_values</code> (via backref of event). When I add a EventFieldValue to <code>event.field_values</code>, it does not reflect in <code>event.fields</code> until I commit the session.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload