Changes between Initial Version and Version 11 of Ticket #26819


Ignore:
Timestamp:
Aug 4, 2016, 9:26:16 PM (10 years ago)
Author:
PREMANAND
Comment:

As you mentioned, implemented fix in validate_unique() method. The above code fixes the issue and all the unit tests got passed.

The only problem is Im not sure how to write the test case. It needs to be simulated as if a user creates a form in the html page. Do you have any pointers for testing similar condition?

row_data = tuple(d._get_pk_val() if hasattr(d, '_get_pk_val') else tuple(d)
                                  if type(d) is list else d for d in row_data)

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #26819

    • Property Component Uncategorized → contrib.postgres
    • Property Triage Stage Unreviewed → Accepted
    • Property Type Uncategorized → Bug
    • Property Owner changed from nobody to PREMANAND
    • Property Status new → assigned
  • Ticket #26819 – Description

    initial v11  
    1 It happens on a second save (when there is already data to be validated)
    2 
    3 On this line: "if row_data in seen_data:", because row_data contains a list and seen_data is a set (row_data: (1, [1, 1]) / seen_data: set())
    4 
    5 Example to reproduce:
    6 
    7 models:
    8 {{{#!python
    9 class Map(models.Model):
    10     name = models.CharField(_('name'), max_length=128)
    11 
    12 
    13 class MapSpot(models.Model):
    14     map = models.ForeignKey('body.Map', related_name='spots')
    15     position = ArrayField(models.IntegerField(), size=2)
    16 
    17     class Meta:
    18         unique_together = [('map', 'position')]
    19 }}}
    20 
    21 admin:
    22 {{{#!python
    23 class MapSpotInline(admin.TabularInline):
    24     model = MapSpot
    25     extra = 0
    26 
    27 
    28 @admin.register(Map)
    29 class MapAdmin(admin.ModelAdmin):
    30     inlines = [MapSpotInline]
    31 }}}
Back to Top