Opened 12 months ago

Closed 10 months ago

Last modified 10 months ago

#22514 closed Bug (fixed)

Postgres index generator does not expect db_type to be None

Reported by: vzima Owned by: vzima
Component: Database layer (models, ORM) Version: 1.6
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Postgres database backend does not expect fields with db_type None in index creation.

Virtual foreign relation can have unique set up to enable model-instance cache. I attach a patch and a test.

Attachments (1)

postgres.patch (3.3 KB) - added by vzima 12 months ago.

Download all attachments as: .zip

Change History (13)

Changed 12 months ago by vzima

comment:1 Changed 12 months ago by timo

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 11 months ago by vzima

  • Has patch set
  • Owner changed from nobody to vzima
  • Status changed from new to assigned
  • Triage Stage changed from Accepted to Ready for checkin

I've made a PR from the patch.

PR: https://github.com/django/django/pull/2687

This patch only patches up the postgres issue. It might be worth to not generate indexes on virtual fields in general.

comment:3 Changed 11 months ago by timo

In the future, please do not mark your own patch as "Ready for checkin". You need to get a second set of eyes to review the patch and then that person can do that. While I don't object to fixing this and am looking at it, note the following deprecation for 2.0: "The DatabaseCreation class on each database backend will be removed, and all table/schema editing will be moved to be via SchemaEditor instead." I guess you may want to see if this issue exists there as well.

comment:4 Changed 11 months ago by vzima

  • Triage Stage changed from Ready for checkin to Accepted

Sorry, I mixed it up with "Ready for code review".

I've run into this issue in 1.6. There is a chance this bug lives on multiple places, but I'd be happier if somebody more familiar with the ORM core check it out.

comment:5 Changed 10 months ago by Tim Graham <timograham@…>

  • Resolution set to fixed
  • Status changed from assigned to closed

In 78c32f1caa9cb9b28be2d867aff586a2016122ed:

Fixed #22514 -- Prevented indexes on virtual fields [postgres].

comment:6 Changed 10 months ago by vzima

Is there any chance for a backport to 1.6? That version is also affected.

comment:7 Changed 10 months ago by timo

Not unless it's a regression from 1.5.

comment:8 Changed 10 months ago by Tim Graham <timograham@…>

In 6e5a7367524d3e3abd3d0f60f2e8a41796908101:

[1.7.x] Fixed #22514 -- Prevented indexes on virtual fields [postgres].

Backport of 78c32f1caa from master

comment:9 Changed 10 months ago by vzima

Found it. It is a regression from 1.5. This is the commit which introduced the bug:

https://github.com/django/django/commit/c698c55966ed9179828857398d27bf69e64713a2

comment:10 Changed 10 months ago by Tim Graham <timograham@…>

In 1892ced10a8c0a74a93acddecdb3329fc58a017b:

Added refs #22514 to 1.6.6 release notes.

comment:11 Changed 10 months ago by Tim Graham <timograham@…>

In ef3ae3d1c94ac1d4ffaeeeec1ee544e91431e65b:

[1.6.x] Fixed #22514 -- Prevented indexes on virtual fields [postgres].

Backport of 78c32f1caa from master

comment:12 Changed 10 months ago by Tim Graham <timograham@…>

In d107c7bd7db183d85bb3b22e0019b3be8af262d2:

[1.7.x] Added refs #22514 to 1.6.6 release notes.

Backport of 1892ced10a from master

Note: See TracTickets for help on using tickets.
Back to Top