On Nov 8, 2008, at 12:32 PM, Allen Bierbaum wrote:

>
> We have been using the declarative successfully in our codebase for a
> couple months now with 0.4.x, but we have just run into a problem.
>
> We have a table we we want to map using declarative but we want to
> have one of the columns be deferred because it contains binary data.
> Unfortunately we can't figure out how to do this.
>
> We tried something like this:
>
> class Person(Base):
>    __tablename__ = 'people'
>    id = Column('id', Integer, primary_key=True)
>    data = Column('data', Binary)
>    __mapper_args__ = {'properties' : {'data' : sa.orm.deferred(data)}
>
> The problem is that when the declarative metaclass assembles the
> arguments to pass to the mapper creation method, this causes two
> arguments of name 'properties' to be passed into the call.  (see
> DeclarativeMeta.__init__)
>
> - Is this a bug in the implementation of declarative?  (perhaps the
> code in DeclarativeMeta.__init__ should look for
> __mapper_args__['properties'] and merge it with the internally created
> properties)
> - Or is there some other way to use deferred columns with declarative?

The names you declare in your Person class *are* the 'properties' that  
get sent to the mapper.  A little bit of inspection on them also  
derives the Columns used for the Table.  I use deferred all the time  
with declarative and its a joy, just say:

class Person(Base):
    data = deferred(Column(Binary))

note the Column name isn't needed either, declarative assigns those  
for you.  I'm using 0.5 but the above should work with 0.4 as well.



--~--~---------~--~----~------------~-------~--~----~
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