#13492: get_or_create(field__iexact=value) fails to set value.
---------------------------------------------------------+------------------
          Reporter:  Chris Dukes <pakrati...@gmail.com>  |         Owner:  
nobody
            Status:  closed                              |     Milestone:       
 
         Component:  Uncategorized                       |       Version:  1.1  
 
        Resolution:  invalid                             |      Keywords:       
 
             Stage:  Unreviewed                          |     Has_patch:  0    
 
        Needs_docs:  0                                   |   Needs_tests:  0    
 
Needs_better_patch:  0                                   |  
---------------------------------------------------------+------------------
Changes (by russellm):

  * status:  new => closed
  * needs_better_patch:  => 0
  * needs_tests:  => 0
  * needs_docs:  => 0
  * resolution:  => invalid

Old description:

> I'm not sure if this is a documentation bug, or a code bug, or operator
> headspace error.
>
> I have a model where a column needs to be unique in a case insensitive
> fashion, but should be stored in a case sensitive fashion.
> I have applied custom SQL for that constraint.
>
> As I am bulk loading the table, I am making use of
> get_or_create(field0__iexact=value0, field1=value1).
> When I use this invocation, field0 ends up being set as null.
>
> If I invoke it as get_or_create(field0__iexact=value0, field0=value0,
> ...)
> I eventually have a constraint error.
>
> I would expect a FieldError if field0__iexact were not permitted, and I
> would expect the fieldname to be calculated from field0__iexact if it
> were permitted.
>
> I am currently avoiding the problem by catching an exception on
> psycopg2.IntegrityError, but that does not seem to be the right solution.
>
> Thanks,
> Chris Dukes

New description:

 I'm not sure if this is a documentation bug, or a code bug, or operator
 headspace error.

 I have a model where a column needs to be unique in a case insensitive
 fashion, but should be stored in a case sensitive fashion.
 I have applied custom SQL for that constraint.

 As I am bulk loading the table, I am making use of
 get_or_create(field0!__iexact=value0, field1=value1).
 When I use this invocation, field0 ends up being set as null.

 If I invoke it as get_or_create(field0!__iexact=value0, field0=value0,
 ...)
 I eventually have a constraint error.

 I would expect a FieldError if field0!__iexact were not permitted, and I
 would expect the fieldname to be calculated from field0!__iexact if it
 were permitted.

 I am currently avoiding the problem by catching an exception on
 psycopg2.IntegrityError, but that does not seem to be the right solution.

 Thanks,
 Chris Dukes

Comment:

 Sounds like you've missed
 [http://docs.djangoproject.com/en/dev/ref/models/querysets/#get-or-create-
 kwargs the section on defaults in the docs].

 For future reference, if you're uncertain if you've found a bug, it's
 better to ask on django-users first.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/13492#comment:1>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to