Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#14691 closed (fixed)

foreign key validate() fails for non-default databases

Reported by: marcop Owned by: nobody
Component: Database layer (models, ORM) Version: dev
Severity: Keywords: validation, foreign key, mutiple_database
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

to reproduce:

  1. configure two databases: default and other
  2. have two models Person and Pet:
    class Person(models.Model):
        name = models.CharField(max_length=100)
    
    class Pet(models.Model):
        name = models.CharField(max_length=100)
        owner = models.ForeignKey(Person)
    
  3. create Person instance named person in database 'other'
  4. create Pet instance named pet in database 'other'
  5. try calling pet.full_clean() or, more specifically, pet._meta.get_field('owner').validate(person.pk, person)

patch and test attached

Attachments (3)

multidb_foreignkey_validation_patch.diff (796 bytes ) - added by marcop 14 years ago.
multidb_management_tests.diff (1.8 KB ) - added by marcop 14 years ago.
14691.diff (1.6 KB ) - added by Ramiro Morales 14 years ago.
Patch with tests

Download all attachments as: .zip

Change History (7)

by marcop, 14 years ago

by Ramiro Morales, 14 years ago

Attachment: 14691.diff added

Patch with tests

comment:1 by Ramiro Morales, 14 years ago

Triage Stage: UnreviewedAccepted

Seems multidb_management_tests.diff you a attached are actually tests for other ticket you opened #14662.

Attached another patch that only adds tests.

comment:2 by Marco Paolini, 14 years ago

oh thanks. My bad.

The bug also affects 1.2

comment:3 by Ramiro Morales, 14 years ago

Resolution: fixed
Status: newclosed

(In [14580]) Fixed #14691 -- Made ForeignKey.validate() use the right database. Thanks Marco Paolini for the report.

comment:4 by Ramiro Morales, 14 years ago

(In [14581]) [1.2.X] Fixed #14691 -- Made ForeignKey.validate() use the right database. Thanks Marco Paolini for the report.

Backport of [14580] from trunk

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