#35077: Quering with int that has bigint in database no longer working.
-------------------------------------+-------------------------------------
     Reporter:  Matej Spiller Muys   |                    Owner:  nobody
         Type:                       |                   Status:  new
  Cleanup/optimization               |
    Component:  Database layer       |                  Version:  5.0
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Simon Charette):

 > I agree that this is dangerous behaviour. But if you model django after
 existing database it can happen.

 I would argue that creating your models by hand from an existing database
 is dangerous by nature and the reported problem here is just a side
 effect. There is [https://docs.djangoproject.com/en/5.0/ref/django-
 admin/#inspectdb a documented way of generating models from a pre-existing
 table] and it should generate the proper mapping.

 > I would expect under or overflow exception to be propagated to the
 caller.

 It is propagated if you validate the data before hand through validation
 errors. If you pass invalid data to a queryset lookup I would say that you
 venture into undefined behaviour territory and changing it to raise an
 exception would be backward compatible. For example, think of all
 `IntegerField` (and it's derivative such as `AutoField` and
 `PositiveIntegerField`) which would result in an unhandled exception when
 doing `SomeModel.objects.get(pk=pk)` and `pk` is used controlled (e.g.
 passed through an url pattern).

 The one premise that the ORM and its query generation machinery must be
 able to assume is that it has a proper Python level schema mapping to the
 tables it's generating SQL for. It you break this premise you should
 expect the unexpected.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/35077#comment:4>
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018cc7b5f612-fa492424-c34b-45e7-92f2-d8cf82089094-000000%40eu-central-1.amazonses.com.

Reply via email to