<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
In classic relational modeling, using ID as the primary key is
common practice. Especially when ORMs are involved. The "id" added
by plugin writers is a natural key so naming it ID goes against
convention. Every field in base models used by plugins has
potential for name collisions. Where does it end? Every column
having a pulp_ or _ prefix? Plugins create relatively few tables
and it doesn't seem unreasonable for plugin writers to select other
names to resolve naming conflicts.<br>
<br>
<div class="moz-cite-prefix">On 05/23/2018 07:50 AM, Brian Bouterse
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAAcvrTF_2ZNvEzKERe+DpduyeSv0XZZEUGfucemGksS+ym1e1A@mail.gmail.com">
<div dir="ltr">
<div>Currently the Content model [0] has 'id' as it's primary
key which is inherited from MasterModel here [1]. By naming
our pk 'id', we are preventing plugin writers from also using
that field. That field name is common for content types. For
example: both RPM and Nuget content also expect to use the
'id' field to store data about the content type itself (not
Pulp's pk). We learned about the Nuget incompatibility at
ConfigMgmgtCamp from a community member. I learned about this
issue with RPM from @dalley.<br>
</div>
<div><br>
</div>
<div>The only workaround a plugin writer has is to call their
field 'rpm_id' or something like that. I don't see how it's
unavoidable that this renaming won't be passed directly onto
the user for things like filtering, creating units, etc. I
think that is an undesirable outcome just so that the Pulp pk
can be named 'id'.</div>
<div><br>
</div>
<div>One option would be to rename 'id' to 'pulp_id' at the
MasterModel. This is also somewhat ugly for Pulp developers,
but it would be (a) crystal clear to the user in all cases and
(b) allow Content writers to model their content types
correctly.</div>
<div><br>
</div>
<div>Another option would be to rename the pk for 'Content'
specifically and not at the MasterModel level. I think that
would create more confusion than benefit so I recommend doing
it at the MasterModel level.<br>
</div>
<div><br>
</div>
<div>What do you all think?</div>
<div><br>
</div>
<div>[0]: <a
href="https://github.com/pulp/pulp/blob/6f492ee8fac94b8562dc62d87e6886869e052e7e/pulpcore/pulpcore/app/models/content.py#L106"
moz-do-not-send="true">https://github.com/pulp/pulp/blob/6f492ee8fac94b8562dc62d87e6886869e052e7e/pulpcore/pulpcore/app/models/content.py#L106</a><br>
</div>
<div>[1]: <a
href="https://github.com/pulp/pulp/blob/d1dc089890f167617fe9917af087d5587708296b/pulpcore/pulpcore/app/models/base.py#L25"
moz-do-not-send="true">https://github.com/pulp/pulp/blob/d1dc089890f167617fe9917af087d5587708296b/pulpcore/pulpcore/app/models/base.py#L25</a></div>
<div><br>
</div>
<div>-Brian<br>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Pulp-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Pulp-dev@redhat.com">Pulp-dev@redhat.com</a>
<a class="moz-txt-link-freetext" href="https://www.redhat.com/mailman/listinfo/pulp-dev">https://www.redhat.com/mailman/listinfo/pulp-dev</a>
</pre>
</blockquote>
<br>
</body>
</html>