<div dir="ltr">I would say it is more than not being "the Django convention" and is in fact a pretty risky schema in general. I think its important to contextualize your question not as a framework one, but a more general database best practices one.<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jan 27, 2021 at 7:00 AM Quirin Pamp <<a href="mailto:pamp@atix.de">pamp@atix.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">




<div dir="ltr">
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
While working on this PR (<a href="https://github.com/pulp/pulp-2to3-migration/pull/295" id="gmail-m_319050838074223389LPlnk249655" target="_blank">https://github.com/pulp/pulp-2to3-migration/pull/295</a>), there was a problem with duplicate units since I added a new "null=True" string field to a unique_together
 condition.</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
It appeared some units ended up having a Null value, while others had the empty string (which was not my intention with respect to the uniqueness condition).</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
I ended up fixing the issue by using "blank=True" instead of "null=True". I also found the following in the django docs:</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Avoid using null on string-based fields such as CharField and TextField because empty string values will always be stored as empty strings, not as NULL. If a string-based field has null=True, that means it has two possible values for “no data”: NULL, and the
 empty string. In most cases, it’s redundant to have two possible values for “no data;” the Django convention is to use the empty string, not NULL.</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
See: <a href="https://docs.djangoproject.com/en/3.1/ref/models/fields/" id="gmail-m_319050838074223389LPlnk" target="_blank">
https://docs.djangoproject.com/en/3.1/ref/models/fields/</a><br>
</div>
<div></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
I am pretty sure I have used "null=True" for string fields within pulp_deb and have also seen examples of it in pulpcore. My question for the community is: Should we be concerned about this, given it is apparently not "the Django convention". Is there any chance
 this could be problematic, even if the field in question is not part of a unique_together condition? Are there situations where we explicitly rely on a distinction between NULL and empty string (making "going against the Django convention" a conscious choice,
 rather than an historical accident)?</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Looking forward to your insights,</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Quirin Pamp (quba42)<br>
</div>
</div>

_______________________________________________<br>
Pulp-dev mailing list<br>
<a href="mailto:Pulp-dev@redhat.com" target="_blank">Pulp-dev@redhat.com</a><br>
<a href="https://www.redhat.com/mailman/listinfo/pulp-dev" rel="noreferrer" target="_blank">https://www.redhat.com/mailman/listinfo/pulp-dev</a><br>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><p style="color:rgb(0,0,0);font-family:overpass,sans-serif;font-weight:bold;margin:0px;padding:0px;font-size:14px;text-transform:uppercase">CALVIN SPEALMAN<br></p><p style="color:rgb(0,0,0);font-family:overpass,sans-serif;font-size:10px;margin:0px 0px 4px;text-transform:uppercase"><span>SENIOR QUALITY ENGINEER</span></p><span style="font-family:overpass,sans-serif;font-size:10px;margin:0px;color:rgb(153,153,153)"></span><span style="color:rgb(0,0,0);font-family:overpass,sans-serif;font-size:medium"></span><span style="color:rgb(0,0,0);font-family:overpass,sans-serif;font-size:medium"></span><p style="font-family:overpass,sans-serif;margin:0px 0px 6px;font-size:10px;color:rgb(153,153,153)"><span style="margin:0px;padding:0px"><a href="mailto:cspealma@redhat.com" target="_blank">cspealma@redhat.com</a> </span> <span>M: <a href="tel:+1.336.210.5107" target="_blank">+1.336.210.5107</a></span></p></div><div dir="ltr"><div><a href="https://red.ht/sig" target="_blank"><img src="https://static.redhat.com/libs/redhat/brand-assets/latest/corp/logo.png" alt="https://red.ht/sig" width="96" height="22"></a><br></div><div><a href="https://redhat.com/trusted" style="color:rgb(204,0,0);font-weight:bold" target="_blank">TRIED. TESTED. TRUSTED.</a></div></div></div></div></div>