Project

Profile

Help

Refactor #4206

Updated by dalley almost 6 years ago

Pulpcore adds a number of fields to models which are likely (or known) to conflict with the names of fields on certain content types.    For instance, errata contain fields named 'id' and 'type', which conflict with the default field names for the pk field and a field used by the MasterModel mechanism, respectively. 

 It was determined after long discussion here [0] that the solution to this should be to make sure all of the fields used by Pulpcore on models that are intended to be extended via the Plugin API are prepended with an underscore character.    Thus: 

 * A primary key field would be created on the base model named '_id' to replace the default-generated 'id' one. 
 * 'type' on MasterModel would be renamed to '_type' 
 * 'notes' would be renamed to '_notes' 
 * And so forth. This is not intended to be an exhaustive list. 

 This is already the case for some fields, such as '_created' and '_last_updated' 

 As part of this issue, we should also switch to using 'pk' instead of 'id' in all Django ORM queries.    'pk' is a psuedonym for whatever the Primary Key field is set to, and will work no matter what said field is named. 

 [0] https://www.redhat.com/archives/pulp-dev/2018-August/msg00019.html

Back