Hi,

We have several legacy database tables that don't have primary keys. With 
older versions of Django, we've hacked it by lying about a field that was 
not a primary key but recent Django versions validate pks more strictly.

Some (but not all) of our legacy tables have multiple primary keys -- i.e. 
are unique only across a few fields.  This harks to the CompositeField work 
and discussion [0].

But CompositeFields are not enough for us, some of our tables are 
essentially append-only, and have no uniqueness constraints across any/all 
fields.  It also seems like CompositeField has stalled several times 
precisely because we are spiking to a very complex end goal.

I'd like to propose, both as an incremental step to CompositeFields and 
something useful in itself, a model Meta option for `without_primary_key` 
-- if Meta.without_primary_key=True then it would turn off the complaints 
during model validation, etc.  One might object that things like 
get/delete/caching can't work with that model.  However those features 
can't be supported in tables without a primary key anyway.

Incrementally, after without_primary_key is implemented/supported, we could 
then add features for models without_primary_key but also has a 
Meta.unique_together value across some fields -- i.e. start trying to 
support inheritance and/or ForeignKey references to those tables, building 
up support.

I've started looking at how deep a change this would be, and believe it's 
pretty tractable.
Before I get too involved with a DEP and PR, what do people think?

/sky

[0] Most recent thread: 
https://groups.google.com/forum/#!searchin/django-developers/primary$20keys|sort:date/django-developers/wakEPFMPiyQ/ke5OwgOPAQAJ

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/47365b24-cd0e-4470-8a77-93ab3a98270f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to