Michael Bayer wrote:
>> Uh oh:
>>
>> sqlalchemy.exc.ArgumentError: Mapper Mapper|Employee|employee could not
>> assemble any primary key columns for mapped table 'employee'
>>
>> ...which makes me wonder if the class decorator would actually work at
>> all. Surely it'll only kick in after the DeclarativeMeta has already
>> done its thing and got upset?
> 
> the mapper is mostly configured by the time the class is done, and the
> primary key columns are required to be there.  The overwhelming use case
> we're talking about here are columns like "created_at", "updated_at",
> etc., not primary keys.

Hmm, well, the primary key column is, in this case, one that wants to be 
shared across all classes...

> But agreed, make your mixin implement a marker class from the declarative
> module (MixinsDeclarative, i dunno),

How about just a marker attribute? How about something in 
__mapper__args__, which already exists?

class MyMixin:

   __mapper_args__ = {'abstract':True}

> and as_declarative() will issue
> copy() for the Column objects within.  It will raise errors for relation()
> since it doesn't make sense to copy those.

I assume this is a feature waiting to be implemented?

What to do in the meantime? The class decorator felt really quite neat 
except that it won't work where primary key columns are added by the 
decorator, right?

Chris

-- 
Simplistix - Content Management, Batch Processing & Python Consulting
            - http://www.simplistix.co.uk

--

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.


Reply via email to