On Jan 26, 2006, at 12:26 PM, Joseph Kocherhans wrote:
http://code.djangoproject.com/wiki/ModelInheritance

Thanks for doing this, Joseph! It looks really good, too, but here are the (inevitable) nitpicks:

1. Modeling parent relations in SQL: #3 seems to make the most sense for me -- I can't think of a case in a one2one where the child id would need to differ from the parent id. Also::

    CREATE TABLE "myapp_restaurant" (
"id" integer NOT NULL PRIMARY KEY REFERENCES "myapp_places" ("id"),
        "description" text NOT NULL
    );

works just fine (at least in Postgres); I'd suggest that SQL relations be used explicitly here.

2. Modeling joins in SQL / lookup API: my general take on this is "make it explicit". If I ask for places, give me a list of places and don't bother looking up restaurants. So:: ``place_instance.description`` should raise an ``AttributeError`` regardless if weather or not it is actually a restaurant.

However, there means there should be a way, given a Place, to get a Restaurant; I would suggest::

        >>> p = Place.objects.get(pk=1)
        >>> r = Restaurant(p)
        >>> i = ItalianRestaurant(p)   # or ...(r)

(I suggest this syntax since it looks like exactly like casting -- ``foo = int(bar)``).

Other than that, this looks GREAT.

Jacob

Reply via email to