Sorry I can't seem to post the following via the Google Groups web interface - 
it's disappeared into the ether twice! So, I'm emailing this: It's in reply  to 
this message:

http://groups.google.com/group/sqlelixir/msg/3fe5762354ccc30d

On Feb 5 2009, 5:45 pm, Tvrtko <[email protected]> wrote:
> > There ought to be a way for the user to tell "I know what I'm doing",
> > and an option only for that seems way overkill.
> 
> Well, this covers it nicely:
> 
> 1. If users says polymorphic=True, then it behaves like now: raises an
> exception when there is a "row_type" column present. This prevents
> unexpected behaviour.
> 
> 2. But, if user says polymorphic="anything", than the user knows what
> column he wants to use for polymorphic column, and if he created such
> column in advance he knows what it will be used for. If there is no
> such
> column, we can add it - just like now.

Tvrtko's suggestion seems reasonable. Did anything come of this? I've just hit 
the problem because I've existing data which was mapped as follows:

class Item(Entity):
    NEWS = 1
    FAQ = 2
    kind = Field(SmallInteger, required=True) #kind has values NEWS or FAQ
    #other fields

Now, I need to create two subclasses, NewsItem and FAQItem, based on the 
existing class. So I added a using_options line:

class Item(Entity):
    using_options(inheritance='single', polymorphic='kind')
    NEWS = 1
    FAQ = 2
    kind = Field(SmallInteger, required=True) #kind has values NEWS or FAQ
    #other fields

of course now, if I try to declare

class NewsItem(Item):
    using_options(identity=Item.NEWS)

then no matter what I do, I get the add_column error because the 'kind' column 
already exists. If I implement Tvrtko's suggestion, then everything works as 
expected.

Should I raise a ticket? I found no tickets referencing add_column in the Trac.

Regards,


Vinay Sajip


      

-- 
You received this message because you are subscribed to the Google Groups 
"SQLElixir" 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/sqlelixir?hl=en.

Reply via email to