Hi all

A subclass is supposed to inherit everything from its parent unless
overridden explicitly. So, why should you prevent it to do so? Imho, it
would make no sense to redeclare options that were set on the parent class
and neither should attributes, methods or anything else. Otherwise, just
define a new class if you do not want to inherit anything.

regards
Andre


On Dec 13, 2007 5:36 PM, Gaetan de Menten <[EMAIL PROTECTED]> wrote:

>
> Hi people,
>
> I just discovered that Elixir has a "feature" I didn't know of: an
> entity will inherit its parent options (in fact all statements) *if*
> that entity has no statement (of *any* kind) itself. This case wasn't
> relevant with the old "statement-based" syntax, since all real-life
> entities had at least one field and hence at least one statement. Now,
> with the new "attribute"-based syntax, this is much more relevant
> since the attributes are not (do not "count" as) statements.
>
> So, for example, with the following entities,
>
> class A(Entity):
>    using_options(tablename="a", order_by="name")
>
>    name = Field(String(20))
>
> class B(A):
>    data = Field(String(20))
>
> B will inherit from A's options, setting the tablename to "a" and the
> order_by to "name". The tablename doesn't cause any problem in this
> case since we (luckily) have single-table inheritance by default, so
> the child Entity's fields will be stored in the parent table anyway.
> The fact that the order_by options is inherited seem pretty logical in
> this case (even if this particular example will fail, due to an
> unrelated bug I also just discovered).
>
> So, basically I wonder what I should do about it:
> - keep the feature "as-is" and just document it.
> - expand the feature so that options are inherited even if the child
> class set some options (obviously if they set an option which is also
> set in the parent, that option get overridden). This might be nice as
> I find in my models than more often than not an option which apply on
> a parent, also applies to its child. By the way, this would be the
> behavior we'd have if we had chosen to set option via special class
> attributes (like __tablename__ = ...).
> - remove that "feature" entirely. This is probably the safest bet.
> - only allow option inheritance for some options and not others. This
> might be too confusing, but without this, you couldn't set some
> options (like tablename) on the parent without setting it on the
> child.
>
> Note that this also applies to the using_mapper_options and
> using_table_options statements.
>
> Any thoughts?
> --
> Gaƫtan de Menten
> http://openhex.org
>
> >
>

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