dum question, i just noticed any() in the docs , sorry

On 3 Paź, 23:08, g00fy <[EMAIL PROTECTED]> wrote:
> i have a problem with filtering by related problem - i want to find
> estates that translated title is "warehouse"
> here are the models:
>
> from estate.model import meta
> from sqlalchemy import Table, Column, Integer, String, ForeignKey,
> Unicode
> from sqlalchemy.orm import mapper, relation, backref
> construction_table = Table('w_construction', meta.metadata,
>                     Column('id', Integer, primary_key=True),
>                     )
>
> warehouse_table = Table('w_warehouse', meta.metadata,
>                     Column('id', Integer, primary_key=True),
>                     Column('construction_id', Integer,
> ForeignKey(construction_table.c.id)),
>                     )
>
> language_table = Table('language', meta.metadata,
>                     Column('code', String(5), primary_key=True),
>                     Column('name', Unicode(20)),
>                     )
>
> currency_table = Table('currency', meta.metadata,
>                     Column('code', String(5), primary_key=True),
>                     Column('name', Unicode(20)),
>                     )
>
> constuction_translation_table = Table('w_construction_translation',
> meta.metadata,
>                     Column('id', Integer, primary_key=True),
>                     Column('construction_id', Integer,
> ForeignKey(construction_table.c.id)),
>                     Column('language_id',
> String(5),ForeignKey(language_table.c.code)),
>                     Column('title', Unicode(512)),
>                     )
>
> translation_table = Table('w_translation', meta.metadata,
>                     Column('id', Integer, primary_key=True),
>                     Column('warehouse_id', Integer,
> ForeignKey(warehouse_table.c.id)),
>                     Column('language_id',
> String(5),ForeignKey(language_table.c.code)),
>                     Column('title', Unicode(512)),
>                     )
>
> price_table = Table('w_price', meta.metadata,
>                     Column('id', Integer, primary_key=True),
>                     Column('currency_id',
> String(5),ForeignKey(currency_table.c.code)),
>                     Column('warehouse_id', Integer,
> ForeignKey(warehouse_table.c.id)),
>                     Column('total', Integer),
>                     )
>
> class Warehouse(object):
>     def __init__(self,id,construction_id):
>         self.id = id
>         self.construction_id = construction_id
>
>     def __repr__(self):
>         return "%s" % self.id
>
> class WarehouseTranslation(object):
>     def __init__(self,id,warehouse_id,language_id,title):
>         self.id = id
>         self.warehouse_id = warehouse_id
>         self.language_id = language_id
>         self.title = title
>
> class Language(object):
>     def __init__(self,code,name):
>         self.code = code
>         self.name = name
>
> mapper(Warehouse, warehouse_table)
> mapper(Language,language_table)
> mapper(WarehouseTranslation,translation_table,properties = {
>     'warehouse': relation(Warehouse,
>                      lazy = False, #1 note lazy here, it means that we
>                                    # will use lazy loading (more
> details in the docs
>                      backref = backref('translations',lazy = False)),
>     'language': relation(Language,
>                          uselist = False,#2 note uselist, it means
>                                          #we use one-to-one instead of
> one-to-many
>                          lazy = False),},
>
>     primary_key = [translation_table.c.warehouse_id,
>                translation_table.c.language_id]
> #explicit primary key is needed when SQLA can not assemble the one
> foryou automatically
> );
>
> here is the code i'm trying to do:
>
> list = meta.Session.query(model.Warehouse)\
>             .filter( model.Warehouse.translations.title.like(u'magazyn
> %')).all()
>
> (there is an error : AttributeError: 'InstrumentedAttribute' object
> has no attribute 'title')
>
> any tips?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to