Re: [sqlalchemy] Passing reference to model to model column_property function

2020-05-18 Thread Erol Merdanović
1. Yes, literal_column does the trick. 2. I have tried with hybrid_method. It also works with literal_column, but the problem here is that it's not including the field automatically in the query? I suspect this is by design, but in my case it's required to execute function so that I get a value

Re: [sqlalchemy] Passing reference to model to model column_property function

2020-05-17 Thread Mike Bayer
On Sun, May 17, 2020, at 6:54 AM, Erol Merdanović wrote: > Hi > > First thank you for your reply. > > @Mike, yes. I wish to pass the row products row. I'm attaching working SQL > >> SELECT *, get_product_price(products) FROM products; > > This works great in postgres. I tried it also on

Re: [sqlalchemy] Passing reference to model to model column_property function

2020-05-17 Thread Erol Merdanović
Hi First thank you for your reply. @Mike, yes. I wish to pass the row products row. I'm attaching working SQL SELECT *, get_product_price(products) FROM products; This works great in postgres. I tried it also on Mysql but they support only scalar values. I suspect that might work with other

Re: [sqlalchemy] Passing reference to model to model column_property function

2020-05-16 Thread Jonathan Vanasco
It’s been a while since I’ve worked on stuff like this, but IIRC the simplest way was to use a function that accepts an ID and to flush in SqlAlchemy before executing it. Then you select the necessary row fields within the sql function, instead of passing args in or trying to pass a row in.

Re: [sqlalchemy] Passing reference to model to model column_property function

2020-05-16 Thread Mike Bayer
On Sat, May 16, 2020, at 1:04 PM, Erol Merdanović wrote: > Hi > > I have a model definition > > class Product(db.Model): > __tablename__ = "products" > > id = db.Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4) > sku = db.Column(db.String(255), nullable=False, unique=True,

[sqlalchemy] Passing reference to model to model column_property function

2020-05-16 Thread Erol Merdanović
Hi I have a model definition class Product(db.Model): __tablename__ = "products" id = db.Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4) sku = db.Column(db.String(255), nullable=False, unique=True, index=True) Product.base_price = column_property(