summaryrefslogtreecommitdiff
path: root/tests/regressiontests/queries/models.py
AgeCommit message (Collapse)Author
2013-02-26Merged regressiontests and modeltests into the test root.Florian Apolloner
2013-02-20Added a test for negated Q object queryingAnssi Kääriäinen
The added test is from the patch in ticket #19672 (written by Ian Kelly). Fixed #19672, refs #19849.
2013-02-19Fixed #19837 -- Refactored split_exclude() join generationAnssi Kääriäinen
The refactoring mainly concentrates on making sure the inner and outer query agree about the split position. The split position is where the multijoin happens, and thus the split position also determines the columns used in the "WHERE col1 IN (SELECT col2 from ...)" condition. This commit fixes a regression caused by #10790 and commit 69597e5bcc89aadafd1b76abf7efab30ee0b8b1a. The regression was caused by wrong cols in the split position.
2012-12-20Fixed #18854 -- Join promotion in disjunction casesAnssi Kääriäinen
The added promotion logic is based on promoting any joins used in only some of the childs of an OR clause unless the join existed before the OR clause addition.
2012-12-16Fixed #10790 -- Refactored sql.Query.setup_joins()Anssi Kääriäinen
This is a rather large refactoring. The "lookup traversal" code was splitted out from the setup_joins. There is now names_to_path() method which does the lookup traveling, the actual work of setup_joins() is calling names_to_path() and then adding the joins found into the query. As a side effect it was possible to remove the "process_extra" functionality used by genric relations. This never worked for left joins. Now the extra restriction is appended directly to the join condition instead of the where clause. To generate the extra condition we need to have the join field available in the compiler. This has the side-effect that we need more ugly code in Query.__getstate__ and __setstate__ as Field objects aren't pickleable. The join trimming code got a big change - now we trim all direct joins and never trim reverse joins. This also fixes the problem in #10790 which was join trimming in null filter cases.
2012-08-21Fixed #17886 -- Fixed join promotion in ORed nullable queriesAnssi Kääriäinen
The ORM generated a query with INNER JOIN instead of LEFT OUTER JOIN in a somewhat complicated case. The main issue was that there was a chain of nullable FK -> non-nullble FK, and the join promotion logic didn't see the need to promote the non-nullable FK even if the previous nullable FK was already promoted to LOUTER JOIN. This resulted in a query like a LOUTER b INNER c, which incorrectly prunes results.
2012-08-12[py3] Refactored __unicode__ to __str__.Aymeric Augustin
* Renamed the __unicode__ methods * Applied the python_2_unicode_compatible decorator * Removed the StrAndUnicode mix-in that is superseded by python_2_unicode_compatible * Kept the __unicode__ methods in classes that specifically test it under Python 2
2012-07-22[py3] Replaced unicode/str by six.text_type/bytes.Aymeric Augustin
2012-06-07Fixed #18269 -- Applied unicode_literals for Python 3 compatibility.Claude Paroz
Thanks Vinay Sajip for the support of his django3 branch and Jannis Leidel for the review.
2012-05-24Fixed qs.order_by() join promotion for already existing joinsAnssi Kääriäinen
When order_by causes new joins to be added to the query, the joins must be LEFT OUTER joins for nullable relations, otherwise the order_by could cause the results to be altered. This commit fixes the logic to only promote new joins, previously all joins in the order_by lookup path were promoted. Thanks to Bruno Desthuilliers for spotting this corner case.
2012-05-09Fix proxy model Query.remove_inherited_models()Anssi Kääriäinen
Fixed #18248 -- proxy models were added to included_inherited_models in sql.query.Query. The variable is meant to be used for multitable inheritance only. This mistake caused problems in situations where proxy model's query was reused.
2012-04-29Simplified QuerySet field.null handlingAnssi Kääriäinen
QuerySet had previously some complex logic for dealing with nullable fields in negated add_filter() calls. It seems the logic is leftover from a time where the WhereNode wasn't as intelligent in handling field__in=[] conditions. Thanks to aaugustin for comments on the patch.
2011-12-22Added support for modifying the effect of ``DISTINCT`` clauses so theyRamiro Morales
only consider some fields (PostgreSQL only). For this, the ``distinct()`` QuerySet method now accepts an optional list of model fields names and generates ``DISTINCT ON`` clauses on these cases. Thanks Jeffrey Gelens and Anssi Kääriäinen for their work. Fixes #6422. git-svn-id: http://code.djangoproject.com/svn/django/trunk@17244 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-10-13Convert the remainder of the relative imports in the tests to be absolute ↵Alex Gaynor
imports. git-svn-id: http://code.djangoproject.com/svn/django/trunk@16981 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-09-30Fixed doc references to `django.db.models.query.QuerySet` and converted some ↵Jannis Leidel
tabs that were introduced in r16699 to spaces. git-svn-id: http://code.djangoproject.com/svn/django/trunk@16915 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-08-23Fixed a broken test from r16656.Malcolm Tredinnick
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16667 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-08-23Fixed an isnull=False filtering edge-case. Fixes #15316.Malcolm Tredinnick
The bulk of this patch is due to some fine analysis from Aleksandra Sendecka. git-svn-id: http://code.djangoproject.com/svn/django/trunk@16656 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-03-08Fixed field names that were preventing the tests from running in Oracle.Ian Kelly
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15774 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-03-03Fixed #12252 -- Ensure that queryset unions are commutative. Thanks to ↵Russell Keith-Magee
benreynwar for the report, and draft patch, and to Karen and Ramiro for the review eyeballs and patch updates. git-svn-id: http://code.djangoproject.com/svn/django/trunk@15726 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-01-25Fixed #11319 - Added lookup support for ForeignKey.to_field. Also reverted ↵Carl Meyer
no-longer-needed model formsets workaround for lack of such support from r10756. Thanks Russell and Alex for review. git-svn-id: http://code.djangoproject.com/svn/django/trunk@15303 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-10-19Converted queries tests from doctests to unittests.Ramiro Morales
Thanks Russell and Alex for reviews and suggestions. git-svn-id: http://code.djangoproject.com/svn/django/trunk@14279 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-10-19Fixed a small typo introduced in r14139.Ramiro Morales
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14272 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-10-11Fixed #12991 -- Added unittest2 support. Thanks to PaulM for the draft ↵Russell Keith-Magee
patch, and to Luke, Karen, Justin, Alex, Łukasz Rekucki, and Chuck Harmston for their help testing and reviewing the final patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@14139 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-09-16Fixed #14244: Allow lists of more than 1000 items to be used with the 'in' ↵Ian Kelly
lookup in Oracle, by breaking them up into groups of 1000 items and ORing them together. Thanks to rlynch for the report and initial patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@13859 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-05-04Fixed #12164 -- Removed the Python 2.3 compatibility imports and ↵Russell Keith-Magee
workarounds. Thanks to timo and claudep for the patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@13094 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-04-15Fixed a test failure under Postgres caused by primary key sequence allocation.Russell Keith-Magee
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12981 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-03-27Fixed #13227 -- Modified ForeignKeys to fully honor the db_prep/prep ↵Russell Keith-Magee
separation introduced by multidb. This was required to ensure that model instances aren't deepcopied as a result of being involved in a filter clause. Thanks to claudep for the report, and Alex Gaynor for the help on the patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@12865 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-03-20Fixed #12239: Fixed results of gte and lt queries when comparing floats to ↵Karen Tracey
integer field values. Thanks waverider, aroy, SmileyChris, and pmclanahan. git-svn-id: http://code.djangoproject.com/svn/django/trunk@12819 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-03-20Fixed #13156 -- Ensure that exists() queries are as fast as they can be. ↵Russell Keith-Magee
Thanks to Jerome Leclanche for the report. git-svn-id: http://code.djangoproject.com/svn/django/trunk@12810 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-01-09Fixed #7235 -- EmptyQuerySet no longer raises and exception when it's ↵Adrian Holovaty
filter()ed (along with some other QuerySet methods). Thanks, taylormarshall git-svn-id: http://code.djangoproject.com/svn/django/trunk@12147 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-12-22Fixed #1142 -- Added multiple database support.Russell Keith-Magee
This monster of a patch is the result of Alex Gaynor's 2009 Google Summer of Code project. Congratulations to Alex for a job well done. Big thanks also go to: * Justin Bronn for keeping GIS in line with the changes, * Karen Tracey and Jani Tiainen for their help testing Oracle support * Brett Hoerner, Jon Loyens, and Craig Kimmerer for their feedback. * Malcolm Treddinick for his guidance during the GSoC submission process. * Simon Willison for driving the original design process * Cal Henderson for complaining about ponies he wanted. ... and everyone else too numerous to mention that helped to bring this feature into fruition. git-svn-id: http://code.djangoproject.com/svn/django/trunk@11952 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-11-19Fixed #12242 -- Corrected a problem with masking extra selects() in a ↵Russell Keith-Magee
DateQuerySet. Thanks to Alex Gaynor for his help debugging this one. git-svn-id: http://code.djangoproject.com/svn/django/trunk@11748 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-08-20Fixed an assumed ordering in the queries regression tests by making it explicit.Matt Boersma
git-svn-id: http://code.djangoproject.com/svn/django/trunk@11474 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-06-07Fixed #11274 -- Corrected doctests to not cause test failures due to missing ↵Brian Rosner
newlines. Thanks Honza Kral. git-svn-id: http://code.djangoproject.com/svn/django/trunk@10941 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-06-06Fixed #11082 -- Ensured that subqueries used in an exclude(X__in=) clause ↵Russell Keith-Magee
aren't pre-evaluated. Thanks to Henry Andrews for the report, and clement for the fix. git-svn-id: http://code.djangoproject.com/svn/django/trunk@10929 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-04-12Added a test from Jamie Gennis to ensure #9848 doesn't reappear.Malcolm Tredinnick
The bug itself was fixed at some point in the past months (there have been a few improvements to update() recently). Fixed #9848. git-svn-id: http://code.djangoproject.com/svn/django/trunk@10528 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-03-24Fixed #9926 -- Fixes for some select_related() situations.Malcolm Tredinnick
Using select_related(...) across a nullable relation to a multi-table model inheritance situation no longer excludes results. Thanks to AdamG for a test demonstrating part of the problem. git-svn-id: http://code.djangoproject.com/svn/django/trunk@10136 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-03-23Fixed a false failure in the test suite when running Oracle.Ian Kelly
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10125 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-03-20Fixed #10547 -- Worked around some odd behaviour in Python 2.3 and 2.4.Malcolm Tredinnick
Calling the super() version of __reduce__ in Model.__reduce__ led to infinite loops in Python prior to 2.5. We don't do that any longer. git-svn-id: http://code.djangoproject.com/svn/django/trunk@10099 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-03-19Fixed #5420 -- Added support for delayed loading of model fields.Malcolm Tredinnick
In extreme cases, some fields are expensive to load from the database (e.g. GIS fields requiring conversion, or large text fields). This commit adds defer() and only() methods to querysets that allow the caller to specify which fields should not be loaded unless they are accessed. git-svn-id: http://code.djangoproject.com/svn/django/trunk@10090 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-03-08Fixed #10432 -- Handle all kinds of iterators in queryset filters.Malcolm Tredinnick
Only consumes the iterators once and works with Python 2.3. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9986 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-03-02Fixed #10181 -- Handle an EmptyResultSet exception case properly in nested ↵Malcolm Tredinnick
querysets. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9951 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-03-01Fixed insert/update handling when no database interaction is required.Malcolm Tredinnick
Fixed #10205 as part of this. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9926 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-03-01Fixed #10202 -- Fixed another couple of slicing edge-cases with querysets.Malcolm Tredinnick
Patch from Alex Gaynor and Ramiro Morales. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9924 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-02-28Fixed #10028 -- Fixed a problem when ordering by related models.Malcolm Tredinnick
Some results were inadvertently being excluded if we were ordering across a nullable relation which itself ordering by a non-nullable relation. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9916 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-01-16Fixed #9997 -- Fixed use of ValuesQuerySets as rvalues in filters.Malcolm Tredinnick
Previous behaviour was pretty stupid. Let's never speak of it again. New behaviour both works and is documented. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9759 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-01-08Fixed #9985 -- qs.values_list(...).values(...) was constructing incorrect SQL.Malcolm Tredinnick
git-svn-id: http://code.djangoproject.com/svn/django/trunk@9717 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-01-08Using querysets as an rvalue in filter() calls was causing an unnecessaryMalcolm Tredinnick
database query, due to a bool() call. This change stops that behaviour. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9715 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-01-05Nested query support.Malcolm Tredinnick
This extends previous functionality that allowed passing Query objects as the rvals to filters. You can now pass QuerySets, which requires less poking at opaque attributes. See the documentation of the "__in" lookup type for the details. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9701 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-01-05Reconciling where- and having-clause behaviour.Malcolm Tredinnick
Extricated the code that works directly with SQL columns (standard "where" stuff) from the the code that takes SQL fragments and combines it with lookup types and values. The latter portion is now more generally reusable. Any existing code that was poking at Query.having will now break in very visible ways (no subtle miscalculations, which is a good thing). This patch, en passant, removes the existing "having" test, since the new implementation requires more setting up than previously. The aggregates support (currently in a separate codebase) has tests for this functionality that work as a replacement for the removed test. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9700 bcc190cf-cafb-0310-a4f2-bffc1f526a37