[sqlalchemy] Re: How can I do this relation?

2010-12-01 Thread Jonathan Gardner
On Nov 30, 3:15 pm, Alvaro Reinoso alvrein...@gmail.com wrote: One region can just contain one channel, but one channel could be in many regions. A region will never be accessed by a channel. However, Channel could be accessed by a region, so I need that relationship in region. Is that

[sqlalchemy] Re: Odd many-to-one problem

2010-11-12 Thread Jonathan Gardner
On Nov 12, 6:42 am, Michael Bayer mike...@zzzcomputing.com wrote: But generally usage of mapper() wasn't intended to provide any tricks around import issues.  You can always use mapper.add_property(...) to attach things as needed, and class_mapper(Class) to call up any mapper anywhere.

[sqlalchemy] Re: Odd many-to-one problem

2010-11-11 Thread Jonathan Gardner
relationship() expects a class or a mapper instance, not a string. I got this error: ArgumentError: relationship 'available_deals' expects a class or a mapper argument (received: type 'str') On Nov 10, 4:46 pm, Sergey V. sergey.volob...@gmail.com wrote: The twist is that I've spread out my

[sqlalchemy] Re: Odd many-to-one problem

2010-11-11 Thread Jonathan Gardner
That is useful for mapping single or combined columns to an attribute. Here, I want to map entire objects. On Nov 10, 10:20 pm, Eric Ongerth ericonge...@gmail.com wrote: Good point, Sergey. Here is the relevant documentation regarding mapping attributes to

[sqlalchemy] Re: Odd many-to-one problem

2010-11-11 Thread Jonathan Gardner
This is what I need to do, except the Merchant object is defined before the Deal object. In the example in the documentation, I have mapped User before I have mapped Address. On Nov 11, 10:25 am, Mike Conley mconl...@gmail.com wrote: For cases like this I have found something like this to be

[sqlalchemy] Odd many-to-one problem

2010-11-10 Thread Jonathan Gardner
I have two tables, merchants and deals. The merchants table is represented by Merchant and deals table by Deal. Each merchant can have 0, 1, or many deals. Some of those deals will be available, while others will be expired or coming soon or deleted. Each deal belongs to exactly one merchant.

[sqlalchemy] Re: Odd many-to-one problem

2010-11-10 Thread Jonathan Gardner
to reorder everything, though. On Nov 10, 11:19 am, Jonathan Gardner jgard...@jonathangardner.net wrote: I have two tables, merchants and deals. The merchants table is represented by Merchant and deals table by Deal. Each merchant can have 0, 1, or many deals. Some of those deals

[sqlalchemy] patch: PGUuid type not compatible with Python uuid module

2009-04-01 Thread Jonathan Gardner
The PGUuid doesn't accept Python's uuid.UUID type. Here's a simple patch to fix that: diff --git a/lib/python2.5/site-packages/SQLAlchemy-0.5.3-py2.5.egg/sqlalchemy/databases/po index 038a9e8..394c293 100755 ---

[sqlalchemy] Re: in operator and literal list

2008-01-08 Thread Jonathan Gardner
Eoghan Murray wrote: Ideally this would be expressed as: MyTable.filter(MyTable.c.MyColumn.in(ls)) Try: MyTable.filter(MyTable.c.MyColumn.in_(ls)) Just a guess. No time to see if this is right. --~--~-~--~~~---~--~~ You received this message

[sqlalchemy] Error with primaryjoin in relation() in 0.4.1

2007-12-29 Thread Jonathan Gardner
I'm getting a strange error when I specify primaryjoin in relation(). Here's a short script to reproduce the error: #!/usr/bin/env python from sqlalchemy import * from sqlalchemy.types import * from sqlalchemy.orm import * engine = create_engine('sqlite:///:memory:', echo=True) metadata =

[sqlalchemy] Re: Error with primaryjoin in relation() in 0.4.1

2007-12-29 Thread Jonathan Gardner
I found the problem goes away if I don't try to overload the names, Still, it would be nice if this wasn't cause a problem. The solution is to rename the columns in table2 to right_id and left_id, and to not use the allow_column_override option in the mapper() function. If that isn't an option,

[sqlalchemy] Re: Error with primaryjoin in relation() in 0.4.1

2007-12-29 Thread Jonathan Gardner
Michael Bayer wrote: the error is because of the allow_column_override, combined with the fact that you haven't reassigned the column attributes for left and right. the left and right columns on table2 need to be available as scalar attributes on your Table2 class since thats how

[sqlalchemy] Missing Sequences

2007-12-18 Thread Jonathan Gardner
I don't know what the design decisions were regarding the Sequence object, so bear with my ignorance for a moment here. I played with SQLAlchemy in conjunction with Pylons. I had code that looked like this: links_table = Table('links', metadata, Column('id', types.Numeric(),

[sqlalchemy] Re: Missing Sequences

2007-12-18 Thread Jonathan Gardner
On Dec 18, 10:39 am, Michael Bayer [EMAIL PROTECTED] wrote: if you can produce decent code, and almost more importantly good unit tests that ensure the decent code always works (else it might as well be broken), commit access is there for the taking. Start with trac tickets, i.e. create some