I need a dynamically calculated column for my model. column_property looks 
great for that, but problem here that it's compiled at time when model is 
mapped and I need to provide some value for filtering at time the request 
is executed. I thought that bindparam can solve that problem for me, but 
found that topic:
https://bitbucket.org/zzzeek/sqlalchemy/issues/3620/new-query-doesnt-expire-column_property

> this is not really a great way to use column_property as it is treated 
> like any other persisted attribute, and is not reloaded unnecessarily. 


so I can't find any proper way to do it, I don't want to use plain 
descriptor property as I have thousands of entries for the model and I 
don't think it's a good idea to emit a new query for each entry.
Here is a simplified example of my models:

User:
  id
  name

Book:
  id
  name

UserFavoriteBooks:
  user_id
  book_id

So I have many-to-many relation between users and books to represent list 
of favorite books for a user. Then some user queries a book from DB and 
want to know if it's in his favorite list, so I need to query the Book 
entry for db with some fake bool column "favorite" which is checked over 
the current user (who performed the request). Is it possible to do that in 
SQLAlchemy so the "favorite" fields is automatically filled with correct 
value once I do a query for a Book?

BR, Evgeny

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to