#22064: Invalid related_name passes silently -------------------------------------+------------------------------------- Reporter: mondone | Owner: elhippie Type: | Status: assigned Cleanup/optimization | Version: master Component: Database layer | Resolution: (models, ORM) | Triage Stage: Accepted Severity: Normal | Needs documentation: 0 Keywords: | Patch needs improvement: 1 Has patch: 1 | UI/UX: 0 Needs tests: 0 | Easy pickings: 1 | -------------------------------------+-------------------------------------
Comment (by carljm): The checks framework is not a runtime code path or a fast path at all, so readability definitely trumps performance here. Barring catastrophic performance issues, which a complex regex can be susceptible to. Looking at the draft patch commit, a few comments: 1. I don't see why the "ends with +" case needs any regex at all. Any related-name ending with "+" is valid, since it won't be used as a Python identifier anyway. (I'm not sure why we even support "ends with +" rather than just "+" -- what's the purpose of including anything before the "+"?). So a simple `.endswith('+')` check should be sufficient there. 2. I'd suggest that we also check the `related_name` against `keyword.iskeyword()`, since using a Python keyword as a related name could also cause trouble. -- Ticket URL: <https://code.djangoproject.com/ticket/22064#comment:8> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/065.6131331782755da39ef2fdf95b7dae6e%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.