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
When i attach a list to the event the aggregate updates correctly
ev=Event.q.get(83) # q is DBSession.query(Event)
ev.base_user_list_id=2
ev.flush()
INFO [sqlalchemy.engine.Engine][MainThread] UPDATE event SET updated_at=%(updated_at)s, base_user_list_id=%(base_user_list_id)s WHERE event.id = %(event_id)s
INFO [sqlalchemy.engine.Engine][MainThread] [cached since 2127s ago] {'updated_at': datetime.datetime(2024, 4, 1, 9, 20, 50, 634580), 'base_user_list_id': 2, 'event_id': 83}
INFO [sqlalchemy.engine.Engine][MainThread] UPDATE user_list SET updated_at=%(updated_at)s, _has_event=(SELECT count(event.id) > %(count_1)s AS anon_1
FROM event
WHERE user_list.id = event.base_user_list_id) WHERE user_list.id IN (%(id_1_1)s)
INFO [sqlalchemy.engine.Engine][MainThread] [generated in 0.00018s] {'updated_at': datetime.datetime(2024, 4, 1, 9, 20, 50, 636710), 'id_1_1': 2}
But when i clear the foreign key in the Event class, the update query is wrong
ev.base_user_list_id=None
ev.flush()
UPDATE event SET updated_at=%(updated_at)s, base_user_list_id=%(base_user_list_id)s WHERE event.id = %(event_id)s
INFO [sqlalchemy.engine.Engine][MainThread] [cached since 233.5s ago] {'updated_at': datetime.datetime(2024, 4, 1, 9, 26, 43, 931450), 'base_user_list_id': None, 'event_id': 83}
INFO [sqlalchemy.engine.Engine][MainThread] UPDATE user_list SET updated_at=%(updated_at)s, _has_event=(SELECT count(event.id) > %(count_1)s AS anon_1
FROM event
WHERE user_list.id = event.base_user_list_id) WHERE user_list.id IN (NULL)
INFO [sqlalchemy.engine.Engine][MainThread] [generated in 0.00067s] {'updated_at': datetime.datetime(2024, 4, 1, 9, 26, 43, 938208), 'count_1': 0}
As you can see in the update query issued by sqlalchey_utils:
UPDATE user_list SET updated_at=..., _has_event=(SELECT count(event.id) > 0 AS anon_1
FROM event
WHERE user_list.id = event.base_user_list_id) WHERE user_list.id IN (NULL)
The update condition is WHERE user_list.id IN (NULL) which is something that never makes sense
Here the query generated should have used the value for base_user_list_id before the update
Also tried adding base_user_list = relationship("BaseUserList", back_populates="event", uselist=False)
but it still results in the exact same query
The text was updated successfully, but these errors were encountered:
I have 2 tables defined as such
When i attach a list to the event the aggregate updates correctly
But when i clear the foreign key in the Event class, the update query is wrong
As you can see in the update query issued by sqlalchey_utils:
The update condition is
WHERE user_list.id IN (NULL)
which is something that never makes senseHere the query generated should have used the value for base_user_list_id before the update
Also tried adding
base_user_list = relationship("BaseUserList", back_populates="event", uselist=False)
but it still results in the exact same query
The text was updated successfully, but these errors were encountered: