Here is how I would construct the colors relation (put this inside
the Product declaration):
Hi Conor,
Thank you for your documented implementation. Works as advertised!
Cheers,
Kees
--~--~-~--~~~---~--~~
You received this message because you are subscribed
Hi,
I simplified my problem to a small example (see model below).
A Product has several Tags attached. A beachball is green, blue, round
and big:
p=Product()
p.name = Beachball
p.tags = [greenTag, blueTag, roundTag, bigTag]
DBSession.save(p)
Often I just want to see the color-related tags, not
Hi,
I'm using the association_proxy example:
http://www.sqlalchemy.org/docs/05/reference/ext/associationproxy.html?highlight=associationproxy#building-complex-views
The example uses this mapper definition:
mapper(Broker, brokers_table, properties={
'by_stock': relation(Holding,
Hi,
This is a table setup in declarative style:
class Category(DeclarativeBase):
__tablename__ = 'category'
category_id = Column(Integer, autoincrement=True,
primary_key=True)
name = Column(Unicode(255), unique=True, nullable=False)
children = relation('Category',
That's it. Thanks!
Although it still took me a while to figure out how to do it. Just to
have a complete example in the mailinglist, I'll copy paste what I
have now:
class Category(DeclarativeBase):
__tablename__ = 'category'
category_id = Column(Integer, autoincrement=True,
Hi,
All the information I need, I can get in 1 SQL query with this query
and model:
categories=Article.query.filter(Article.parent == None).all()
class Article(DefaultEntity):
name = Field(Unicode(64), index=True)
parent = ManyToOne('Article')
children = OneToMany('Article',
On Jul 31, 7:55 pm, Michael Bayer mike...@zzzcomputing.com wrote:
or_() returns the first argument if theres only one argument. youre
looking for or_(*map(...))
Thanks, that's exactly what I was looking for.
--~--~-~--~~~---~--~~
You received this message
Hi,
I'd like to create a query at run time with any amount of filters
wrapped in an 'OR'.
What's the right syntax to do this?
This was my best attempt so far:
from sqlalchemy import *
id=[1,2]
q=Province.query.filter(or_(map(lambda n: Province.id == n, id)))