Re: [sqlalchemy] How to custom 'merge' behavior of a column type?

2020-09-15 Thread Mike Bayer
On Tue, Sep 15, 2020, at 12:02 AM, sonsshh wrote: > Hi Mike, > > My use case involves receiving a lot of data over the network, processing on > the model and persisting them. > Therefore, using the manual approach would be quite inefficient. session.merge() is not any more efficient than what

Re: [sqlalchemy] How to custom 'merge' behavior of a column type?

2020-09-14 Thread sonsshh
Hi Mike, My use case involves receiving a lot of data over the network, processing on the model and persisting them. Therefore, using the manual approach would be quite inefficient. Currently I have to use raw sql and session.execute(), is this the only way? Is there any other way for example

Re: [sqlalchemy] How to custom 'merge' behavior of a column type?

2020-09-13 Thread Mike Bayer
you would need to accomplish this manually. existing_obj = session.query(MyClass).get(obj.id) if existing_obj is not None: existing_obj.links.extend(obj.links) obj = session.merge(obj) On Sat, Sep 12, 2020, at 3:45 AM, sonsshh wrote: > Hi, > > I'm trying to change the behavior of

[sqlalchemy] How to custom 'merge' behavior of a column type?

2020-09-12 Thread sonsshh
Hi, I'm trying to change the behavior of Postgres ARRAY type when calling *session.merge(obj)* where *obj* has a *links *ARRAY(Text) column. What I want is as below: *obj = Obj(links=['link2'],...)* *in DB I have obj row already and obj.links=['link1']* *session.merge(obj)* *