Re: [sqlalchemy] Foreign key from inside JSONB field

2019-10-28 Thread João Miguel Neves
Brilliant, wasn't aware I could pass a function to primary join. Thank you very much (for this, sqlalchemy and your amazing support), João On Mon, 28 Oct 2019, 16:33 Mike Bayer, wrote: > It might not work great with more complex usage so may not be worth it, > however, the lazyload can succeed

Re: [sqlalchemy] Foreign key from inside JSONB field

2019-10-28 Thread Mike Bayer
It might not work great with more complex usage so may not be worth it, however, the lazyload can succeed here with some more explicit casts, also the json attribute is the "foreign" part here because it's the part that references something else. Here's your POC from sqlalchemy import cast fro

[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):