kvesteri / sqlalchemy-continuum

Versioning extension for SQLAlchemy.
BSD 3-Clause "New" or "Revised" License
582 stars 125 forks source link

does not create new version when using upset #235

Open cyzanfar opened 4 years ago

cyzanfar commented 4 years ago

I have this code running that does an "upset" to my pg db:

        stmt = insert(Flight).values(
            chunk.to_dict(orient='records'))

        on_update_stmt = stmt.on_conflict_do_update(
            index_elements=['flight_id'],
            set_={c.key: c for c in stmt.excluded if c.key not in ['id', 'created_at', 'updated_at']})

        db.session.execute(on_update_stmt)
        db.session.commit()

the problem is that continuum is not picking up those update changes. Any idea what's going on? Is this just not implemented yet?

kslotay commented 4 years ago

Had the same issue a couple of weeks ago. Ended up writing my own pre-update caching/batching mechanism, used regex to filter updates, and then used a cron job to lookup and manually update audit logs.

enertel commented 4 years ago

I'm also running into this issue with this, any traction on it?

update_cols = [c.name for c in table.c if c not in list(table.primary_key.columns)]
stmt = insert(table).values(values)
upsert_stmt = stmt.on_conflict_do_update(
        constraint="balauthority_name_key",
        set_={k: getattr(stmt.excluded, k) for k in update_cols}
    )
db.session.execute(upsert_stmt)
db.session.commit()