On Nov 16, 2010, at 6:16 AM, Enrico Morelli wrote:
> On Mon, 15 Nov 2010 15:56:06 -0500
> Michael Bayer <[email protected]> wrote:
>
>> its looking for a Column object. menus_table.c.weight instead of
>> 'weight'.
>>
>
> Thanks, I modified the query:
> main_menu = Session.query(Menu).filter(and_(Menu.parent_id==None,
> Menu.lang==session['lang'])).order_by(menus_table.c.weight.asc()).all()
>
> but the error is the same:
>
> ArgumentError: Column-based expression object expected for argument
> 'order_by'; got: 'weight', type <type 'str'>
no , the mapping:
mapper(Menu, menus_table,
properties={
'children': relation(Menu, order_by=menus_table.c.weight),
'permissions': relation(Permissions, backref='menus',
secondary=menus_permissions_table)
})
>
>>
>> On Nov 15, 2010, at 10:03 AM, Enrico Morelli wrote:
>>
>>> Dear all,
>>>
>>> I've a lot of applications using SA 0.5.6. Now I upgraded my
>>> personal computer and now I can use SA 0.6.5 but my applications
>>> stops to work.
>>>
>>> I receive the error:
>>> ArgumentError: Column-based expression object expected for argument
>>> 'order_by'; got: 'weight', type <type 'str'>
>>>
>>> I try to search in google but I don't understand why I receive this
>>> error. Someone can explain to me?
>>>
>>> Thanks in advance
>>>
>>> This is the table declaration:
>>>
>>> menus_table = Table('menus', metadata,
>>> Column('id', types.Integer, primary_key=True),
>>> Column('parent_id', types.Integer, ForeignKey('menus.id')),
>>> Column('name', types.Unicode(80), nullable=False),
>>> Column('title', types.Unicode(80)),
>>> Column('url', types.Unicode(80)),
>>> Column('weight', types.Integer, index=True),
>>> Column('lang', types.Unicode(2))
>>> )
>>>
>>> This is the mapper declaration:
>>> mapper(Menu, menus_table,
>>> properties={
>>> 'children': relation(Menu, order_by='weight'),
>>> 'permissions': relation(Permissions, backref='menus',
>>> secondary=menus_permissions_table)
>>> })
>>>
>>> At the end the query:
>>> main_menu = Session.query(Menu).filter(and_(Menu.parent_id==None,
>>> Menu.lang==session['lang'])).order_by(Menu.weight.asc()).all()
>>>
>>> --
>>> -------------------------------------------------------------------
>>> (o_
>>> (o_ //\ Coltivate Linux che tanto Windows si pianta da solo.
>>> (/)_ V_/_
>>> +------------------------------------------------------------------+
>>> | ENRICO MORELLI | email: [email protected] |
>>> | * * * * | phone: +39 055 4574269 |
>>> | University of Florence | fax : +39 055 4574253 |
>>> | CERM - via Sacconi, 6 - 50019 Sesto Fiorentino (FI) - ITALY |
>>> +------------------------------------------------------------------+
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "sqlalchemy" group. To post to this group, send email to
>>> [email protected]. 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.
>>>
>>
>
>
> --
> -------------------------------------------------------------------
> (o_
> (o_ //\ Coltivate Linux che tanto Windows si pianta da solo.
> (/)_ V_/_
> +------------------------------------------------------------------+
> | ENRICO MORELLI | email: [email protected] |
> | * * * * | phone: +39 055 4574269 |
> | University of Florence | fax : +39 055 4574253 |
> | CERM - via Sacconi, 6 - 50019 Sesto Fiorentino (FI) - ITALY |
> +------------------------------------------------------------------+
>
> --
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To post to this group, send email to [email protected].
> 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.
>
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
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.