Re: [sqlalchemy] Behaviour when setting a foreign key column.

2020-12-14 Thread João Miguel Neves
t; > > https://docs.sqlalchemy.org/en/13/faq/sessions.html#i-set-the-foo-id-attribute-on-my-instance-to-7-but-the-foo-attribute-is-still-none-shouldn-t-it-have-loaded-foo-with-id-7 > > Hope that helps, > > Simon > > On Mon, Dec 14, 2020 at 12:50 PM João Miguel Neves &g

[sqlalchemy] Behaviour when setting a foreign key column.

2020-12-14 Thread João Miguel Neves
Hi all, I'm sorry, as I feel like this is kind of a beginner question. I'd expect that when I set a column attribute the respective relationship field would change or at least be marked as changed (so a posterior access can be loaded later on another access), but I've found a case where it

Re: [sqlalchemy] SQLAlchemy Memory Leak

2020-02-26 Thread João Miguel Neves
Hi, When you go through the objects, do you remove them from the session with session.expire(obj)? Hope this helps, João On Wed, 26 Feb 2020 at 17:09, Ahmed Cheikh wrote: > Hello Everybody, > > I used SQLAlchemy in one of my projects. And in this project, I loop over > many objects. I use for

Re: [sqlalchemy] Foreign key from inside JSONB field

2019-10-28 Thread João Miguel Neves
metadata.drop_all(e) > Base.metadata.create_all(e) > > s = Session(e) > > d1 = Department(department_id=1) > s.add(d1) > s.add(Project(meta={"department_id": 1})) > s.commit() > > p1 = s.query(Project).first() > assert p1.department is d1 > &

[sqlalchemy] Foreign key from inside JSONB field

2019-10-28 Thread João Miguel Neves
Hi, I'm not sure this is supported or intended to work, but I'm trying to use a value inside a JSONB field in a relationship. class Department(DeclarativeBase): __tablename__ = "department" department_id = Column(Integer, autoincrement=True, primary_key=True) class Project(DeclarativeBase):

Re: [sqlalchemy] Issue with bulk updates on ORM and PostgreSQL

2019-06-17 Thread João Miguel Neves
the previous situation where it silently lost one of the updates, but slightly worst than the update with synchronize_session if it would work with inheritance). I'm assuming there's no other alternative? Thanks in advance, João On Fri, Jun 14, 2019 at 5:52 PM João Miguel Neves < joao.silva

Re: [sqlalchemy] Issue with bulk updates on ORM and PostgreSQL

2019-06-14 Thread João Miguel Neves
Cool, wasn't aware of that feature! Thanks! On Fri, Jun 14, 2019 at 5:50 PM Mike Bayer wrote: > > > On Fri, Jun 14, 2019, at 12:46 PM, Mike Bayer wrote: > > > > On Fri, Jun 14, 2019, at 12:22 PM, João Miguel Neves wrote: > > Not performance, actually to avoid a rac

Re: [sqlalchemy] Issue with bulk updates on ORM and PostgreSQL

2019-06-14 Thread João Miguel Neves
ializer"](value), ) }, synchronize_session="fetch", ) On Fri, Jun 14, 2019 at 5:07 PM Mike Bayer wrote: > > > On Fri, Jun 14, 2019, at 11:49 AM, João Miguel Neves wrote: > > Hi Mike, > > Thank you very much for the quick response! > > Is there any other way to find

Re: [sqlalchemy] Issue with bulk updates on ORM and PostgreSQL

2019-06-14 Thread João Miguel Neves
, Jun 14, 2019 at 4:04 PM Mike Bayer wrote: > > > On Fri, Jun 14, 2019, at 10:30 AM, João Miguel Neves wrote: > > Hi, > > I have a situation where an update tries to update the wrong table on when > a column comes from the parent table and is not on the current table. I'l

[sqlalchemy] Issue with bulk updates on ORM and PostgreSQL

2019-06-14 Thread João Miguel Neves
Hi, I have a situation where an update tries to update the wrong table on when a column comes from the parent table and is not on the current table. I'll grant I didn't quite understand all the caveats in https://docs.sqlalchemy.org/en/13/orm/query.html#sqlalchemy.orm.query.Query.update so