Re: [Django] #20301: Unique field validation with multiple DB connections.

2015-07-29 Thread Django
#20301: Unique field validation with multiple DB connections.
-+-
 Reporter:  SardarNL |Owner:  nobody
 Type:  Bug  |   Status:  closed
Component:  Database layer   |  Version:  master
  (models, ORM)  |
 Severity:  Normal   |   Resolution:  duplicate
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by timgraham):

 * status:  new => closed
 * resolution:   => duplicate


Comment:

 Duplicate of #15130

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.41ceb68b0dc140d7469f89e7e3c23e25%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #20301: Unique field validation with multiple DB connections.

2013-04-22 Thread Django
#20301: Unique field validation with multiple DB connections.
-+-
 Reporter:  SardarNL |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  master
  (models, ORM)  |   Resolution:
 Severity:  Normal   | Triage Stage:  Accepted
 Keywords:   |  Needs documentation:  0
Has patch:  0|  Patch needs improvement:  0
  Needs tests:  0|UI/UX:  0
Easy pickings:  0|
-+-
Changes (by jacob):

 * needs_better_patch:   => 0
 * needs_docs:   => 0
 * needs_tests:   => 0
 * stage:  Unreviewed => Accepted


-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[Django] #20301: Unique field validation with multiple DB connections.

2013-04-22 Thread Django
#20301: Unique field validation with multiple DB connections.
--+
 Reporter:  SardarNL  |  Owner:  nobody
 Type:  Bug   | Status:  new
Component:  Database layer (models, ORM)  |Version:  master
 Severity:  Normal|   Keywords:
 Triage Stage:  Unreviewed|  Has patch:  0
Easy pickings:  0 |  UI/UX:  0
--+
 `django.db.models.base._perform_unique_checks` is not using
 `self._state.db` to lookup unique fields. Check the following:

 {{{
 class MyModel(models.Model):
my_unique = models.IntegerField(unique=True)

 obj = MyModel(my_unique=value_exists_on_default_new_on_other_connection)
 obj._state.db = other_connection
 obj.full_clean()

 # for existing objects _state.db will be already set
 obj = MyModel.objects.using(other_connection).get(pk=existing)
 obj.my_unique = value_exists_on_default_new_on_other_connection
 obj.full_clean()
 }}}

 `full_clean()` will `validate_unique()` -> `_perform_unique_checks()`,
 which will eventually `qs =
 model_class._default_manager.filter(**lookup_kwargs)`. The default manager
 is always using default connection, so unique check will be performed on
 default connection. Other validators, such as ForeignKey lookup, properly
 use `.using()` to keep talking to the database where the object came from.

 Fix: {{{ qs =
 model_class._default_manager.filter(**lookup_kwargs).using(self._state.db)
 }}}
 The same fix is needed for `_perform_date_checks()`.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.