Thank you Craig for bringing this up and for offering support. This is a long-wanted feature —the original ticket is 12 (!) years old— and as you know there has been extensive work done on this in the past, so it'd be great to find a way to push this all the way across the finish line.
I just took a bit of time and tried to review all past discussions and implementations on the subject. See my recap and questions below. If anyone here on this list has any answers or thoughts about this, please jump in! I will then compile all new feedback and try to help move this forward.
Composite fields DEPs
==================
Currently the consensus as a first step is to finalize these two draft DEPs:
https://github.com/django/deps/blob/master/draft/0191-composite-fields.rst
https://github.com/django/deps/blob/master/draft/0192-standalone-composite-fields.rst
Those drafts were written by Thomas Stephenson in 2015 and were discussed on this thread: https://groups.google.com/forum/#!topic/django-developers/MZUcOE6-7GY as well as in this pull request: https://github.com/django/deps/pull/12
It seems that some extra topics might need to be included and fleshed out in those DEPs, in particular:
- Inspectdb integration
- Migration implications
- Form fields handling
- Admin integration
- Serialization/deserialization
Some questions:
- Do you agree that all the topics above should be covered in the DEPs?
- Should other topics also be covered?
- Are the current design details (observer pattern, lookup functions, constraints management, etc) already accepted or do they still need more discussion?
Thomas had also started an implementation for these DEPs in this branch: https://github.com/ovangle/django/tree/dep_191
I've just merged current master into that branch and pushed it to my fork. You can see the details here: https://github.com/django/django/compare/eb97af0402536a86d5d8c916859986288bb88dc9...jphalip:dep_191
Some questions:
- What is the status of this implementation work?
- What are the pieces that still need to be implemented in order to fulfill the existing DEPs?
- Is this implementation at a stage where it can formally be reviewed? If so I can create a PR to initiate a more detailed discussion.
Composite primary keys (GSoC)
=========================
Michal Petrucha participated in two Google Summer of Code (GSoC) projects in 2011 and 2013, during which some extensive code, tests and documentation were written. Unfortunately this project didn't reach the point where it could be merged into core and it eventually fell behind. Some relevant resources about these projects can be found here:
- GSoC'2013 proposal: https://gist.github.com/koniiiik/5408673
- GSoC'2013 status updates: https://groups.google.com/forum/#!topic/django-developers/CD7OrkJ63zc
- Discussion about some implementation details: https://github.com/django/django/pull/1407
- Status update from Michal from last year: https://groups.google.com/forum/#!topic/django-developers/SunyXc_BTVM
Michal's implementation work is divided in two separate branches ("composite-fields" and "foreignkey-refactor"), presented below with their corresponding list of commits:
"composite-fields" branch:
- Branch: https://github.com/koniiiik/django/tree/soc2013/composite-fields
"foreign-refactor" branch:
- Branch: https://github.com/koniiiik/django/tree/soc2013/foreignkey-refactor
I took a quick stab at merging current master into those branches but didn't make it too far as it turned out to be a little tedious. The main reason is that since 2013 there have been extensive changes in the ORM internals, in particular around the Meta api. So I'm not sure if it's worth doing that merge at this point. However, it'd be a shame to let all that great work go to waste and hopefully some of it can still be reused.
Some questions:
- Are there any portions of code or some solutions from Michal's implementation that could be ported over to the DEPs and to Thomas' more recent implementation?
- What is the difference or relationship between the "composite-fields" and "foreignkey-refactor" branches?
- Should a new DEP be submitted to specifically tackle composite primary keys and foreign keys?
Other resources
============
Open tickets relating to this subject:
- Original ticket for composite primary keys: https://code.djangoproject.com/ticket/373
- Support for Virtual Fields: https://code.djangoproject.com/ticket/16508
Third-party implementations of composite fields and composite primary keys:
- https://github.com/simone/django-compositekey
- https://github.com/vporton/django-composite-fields
- https://bitbucket.org/bikeshedder/django-composite-field
Other relevant links:
- Out-dated Django wiki page: https://code.djangoproject.com/wiki/MultipleColumnPrimaryKeys
- SQL Alchemy's PrimaryKeyConstraint API: http://docs.sqlalchemy.org/en/latest/core/constraints.html#sqlalchemy.schema.PrimaryKeyConstraint
That's about it for now. Again, please anyone feel free to jump in with any questions or feedback, or if you're interested in contributing to this work.
Thanks!
Hi Julian,I have been also reviewing and studying the previous works, deps, discussions, codes and tickets. I have also been working to prepare a new dep based on the previous works.
--Roger Gammans <rgam...@gammascience.co.uk>
--
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+unsubscribe@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/cc29383b-b930-4d4c-9f48-51fa10909ecd%40googlegroups.com.
--
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+unsubscribe@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/20170227204442.GY23772%40koniiiik.org.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscribe@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/dae2ef67-99cf-4782-96fb-a399a3bb6ae3%40googlegroups.com.