SQLAlchemy update PostgreSQL array using merge not work

后端 未结 2 1217
悲&欢浪女
悲&欢浪女 2020-12-11 20:30

I\'m using SQLAlchemy to access PostgreSQL database, and I defined the object like this:

class SessionLog(Base):
    __tablename__ = \'session_log\'

    id          


        
2条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-11 20:45

    the SQLAlchemy ORM relies upon detection of events in order to tell when some data has changed, and thus when data needs to be flushed. in this case, you are altering the Python array value in-place, which does not by default produce any events. In order for this to work you need to use the mutable extension in conjunction with the ARRAY type (as well as a list subclass which sends these events) in order for changes to be sent as events related to the parent SessionLog object.

提交回复
热议问题