Ticket #18320: django-ticket18320.2.diff

File django-ticket18320.2.diff, 1.5 KB (added by manfre, 3 years ago)

Added feature 'query_needed_to_fetch_return_id'

  • django/db/backends/__init__.py

    diff --git a/django/db/backends/__init__.py b/django/db/backends/__init__.py
    index 2762350..81d5081 100644
    a b class BaseDatabaseFeatures(object): 
    328328
    329329    can_use_chunked_reads = True
    330330    can_return_id_from_insert = False
     331    query_needed_to_fetch_return_id = False
     332   
    331333    has_bulk_insert = False
    332334    uses_autocommit = False
    333335    uses_savepoints = False
  • tests/regressiontests/model_formsets_regress/tests.py

    diff --git a/tests/regressiontests/model_formsets_regress/tests.py b/tests/regressiontests/model_formsets_regress/tests.py
    index f1e935e..8b6c571 100644
    a b  
    11from __future__ import absolute_import
    22
    33from django import forms
     4from django.db import connection
    45from django.forms.formsets import BaseFormSet, DELETION_FIELD_NAME
    56from django.forms.util import ErrorDict, ErrorList
    67from django.forms.models import modelform_factory, inlineformset_factory, modelformset_factory, BaseModelFormSet
    class FormsetTests(TestCase): 
    255256                u'test-INITIAL_FORMS': u'0',
    256257                u'test-MAX_NUM_FORMS': u'',
    257258                u'test-0-name': u'Random Place', }
    258         with self.assertNumQueries(1):
     259        expected_num_queries = 1
     260        if connection.features.query_needed_to_fetch_return_id:
     261            expected_num_queries = 2
     262        with self.assertNumQueries(expected_num_queries):
    259263            formset = Formset(data, prefix="test")
    260264            formset.save()
    261265
Back to Top