#21508: ForeignKey cast to int despite being varchar
-------------------------------------+-------------------------------------
     Reporter:  fiomtec@…            |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  1.5
  (models, ORM)                      |               Resolution:
     Severity:  Normal               |             Triage Stage:
     Keywords:                       |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by fiomtec@…):

 Ok, I've been doing a bit more testing. It seems that it doesn't have to
 do with the column being a ForeignKey, but with the db column being a
 foreign key. I've redefined my model like this:


 {{{
 class Confirmacion(models.Model):
     cliente = models.CharField(db_column='entidad_propietaria',
 max_length=8)
     fecha_orden = models.CharField(max_length=8)
     [...]other fields[...]
 }}}

 When I query some objects, fecha_orden will always be a string (despite it
 being a date in the form YYYYMMDD), but cliente will be a string if it's
 something like 'MADRID', but an integer if it can be converted.

 Both columns are defined as varchar(8) not null in the database, the only
 difference is that entidad_propietaria is a foreign key to another table,
 and fecha_orden isn't.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/21508#comment:2>
Django <https://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 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/075.ae1a8ffa063f3a4b3b1ae28b29ef55d2%40djangoproject.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to