Skip to content

5.2.3 regression with .annotate that forbids overriding existing fieldsΒ #2818

@sobolevn

Description

@sobolevn

Refs #2797

Quoting @asottile-sentry from #2797 (comment)


I believe this might not be correct for the .annotate(...) case

here's an example from sentry:

src/sentry/api/serializers/models/rule.py:207: error: Attribute "date_added" already defined on "sentry.models.rulefirehistory.RuleFireHistory"  [no-redef]

https://github.com/getsentry/sentry/blob/e1829e8cbd0fe4179e137afbbee23b06d35d3eee/src/sentry/api/serializers/models/rule.py#L209

(there's a few other examples in sentry as well where particular aggregations are used to produce a value with the same name as an existing field when making a grouped query)


Quoting myself from #2797 (comment)


Hm, interesting, I haven't consider this use-case. So, basically, if we annotate an some existing IntegerField field with int value, there's no type error here. So, basically, we should instead detect type mismatches in annotated fields and report them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions