From 0837eacc4e1fa7916e48135e8ba43f54a7a64997 Mon Sep 17 00:00:00 2001 From: Michael Manfre Date: Wed, 8 Jan 2014 23:31:34 -0500 Subject: Made SQLCompiler.execute_sql(result_type) more explicit. Updated SQLUpdateCompiler.execute_sql to match the behavior described in the docstring; the 'first non-empty query' will now include all queries, not just the main and first related update. Added CURSOR and NO_RESULTS result_type constants to make the usages more self documenting and allow execute_sql to explicitly close the cursor when it is no longer needed. --- tests/backends/tests.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests/backends') diff --git a/tests/backends/tests.py b/tests/backends/tests.py index 0ff3ad0bba..4a3fc31b7a 100644 --- a/tests/backends/tests.py +++ b/tests/backends/tests.py @@ -20,6 +20,7 @@ from django.db.backends.utils import format_number, CursorWrapper from django.db.models import Sum, Avg, Variance, StdDev from django.db.models.fields import (AutoField, DateField, DateTimeField, DecimalField, IntegerField, TimeField) +from django.db.models.sql.constants import CURSOR from django.db.utils import ConnectionHandler from django.test import (TestCase, TransactionTestCase, override_settings, skipUnlessDBFeature, skipIfDBFeature) @@ -209,7 +210,7 @@ class LastExecutedQueryTest(TestCase): """ persons = models.Reporter.objects.filter(raw_data=b'\x00\x46 \xFE').extra(select={'föö': 1}) sql, params = persons.query.sql_with_params() - cursor = persons.query.get_compiler('default').execute_sql(None) + cursor = persons.query.get_compiler('default').execute_sql(CURSOR) last_sql = cursor.db.ops.last_executed_query(cursor, sql, params) self.assertIsInstance(last_sql, six.text_type) -- cgit v1.3