Skip to content

Normalize lowercase name lookups at the field level - #652

Draft
terjekv wants to merge 1 commit into
masterfrom
agent/field-aware-name-lookups
Draft

terjekv wants to merge 1 commit into
masterfrom
agent/field-aware-name-lookups

Conversation

@terjekv

@terjekv terjekv commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

Lowercase name lookups currently depend on whether a caller uses a manager, a chained queryset, or a view mixin. For example, an uppercase member name fails through an M2M detail queryset, and applying the manager's normalization to every queryset also corrupts regex escapes such as \D.

This change registers literal-value lookups on LowerCaseCharField (inherited by LowerCaseDNSNameField). Direct and chained queries, Q objects, joins, related managers, and collection lookups now share normalization. Regex patterns, ordinary fields, and explicit expressions/transforms retain Django's semantics. Existing manager classes remain available for compatibility, including the NetManager combination, and redundant query-time normalization is removed from views.

The database schema and lowercase storage behavior are unchanged. Exact queries normalize their parameters without wrapping indexed columns in SQL functions. docs/name_lookups.md documents the supported lookup behavior.

Validation

  • 23 new ORM and API regression tests cover direct/chained lookups, Q/negation, collections and generators, joins, prefetched relations, M2M operations, owner case sensitivity, regex escapes, expressions/transforms, SQL parameters, and NetManager compatibility.
  • Full Django 5.2.16 and 6.0.7 suites on Python 3.12 with PostgreSQL 18.4: 981 tests passed on each version (2 existing skips per run).
  • Overall coverage: 97.75%; the new lookup module has 100% line coverage.
  • Ruff, migration checks, and OpenAPI schema validation passed.

Related: #650, #651.

@coveralls

coveralls commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

Coverage Status

coverage: 97.713% (+0.04%) from 97.672% — agent/field-aware-name-lookups into master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants