summaryrefslogtreecommitdiff
path: root/django/db/models/sql
AgeCommit message (Collapse)Author
2012-03-22Used SortedDict instead of dict to avoid random errors that may occur when ↵Aymeric Augustin
dict randomization is enabled in Python. Refs #17758. Thanks Łukasz Rekucki. git-svn-id: http://code.djangoproject.com/svn/django/trunk@17777 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2012-03-13Fixed #10498 (again) -- Made sure the improvements done in r17641 have a ↵Jannis Leidel
smaller impact on speed. Thanks to Anssi Kääriäinen for the patch and Jonas Obrist for reviewing. git-svn-id: http://code.djangoproject.com/svn/django/trunk@17698 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2012-02-22Fixed #17728 -- When filtering an annotation, ensured the values used in the ↵Aymeric Augustin
filter are properly converted to their database representation. This bug was particularly visible with timezone-aware DateTimeFields. Thanks gg for the report and Carl for the review. git-svn-id: http://code.djangoproject.com/svn/django/trunk@17576 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2012-02-22Fixed #17678 -- Corrected setup of _meta.proxy_for_model and added ↵Carl Meyer
_meta.concrete_model. Thanks Anssi Kääriäinen. git-svn-id: http://code.djangoproject.com/svn/django/trunk@17573 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2012-02-05Fixed #11670 -- Prevented genuine model fields named 'year', 'month', 'gt', ↵Julien Phalip
'lt' etc. from being mistaken for lookup types in lookups across relations. Thanks to andy for the report, to jpwatts for the initial patch and to Anssi Kääriäinen and Alex Gaynor for the reviews. git-svn-id: http://code.djangoproject.com/svn/django/trunk@17450 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2012-01-03Fixed #17429 -- Ensured that `Meta.ordering=None` works the same if it were ↵Julien Phalip
an empty list. Thanks to self[at]dicos[dot]ru for the report and to bigkevmcd for the patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@17334 bcc190cf-cafb-0310-a4f2-bffc1f526a37
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-12-17Fixed various dodgy behavioursAdrian Holovaty
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17226 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-11-13Fixed #13640: Avoid generating an exception when a model has an attribute ↵Karen Tracey
named 'evaluate'. Thanks LukaszKorzybski and tobias. git-svn-id: http://code.djangoproject.com/svn/django/trunk@17093 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-10-18Remove all relative imports. We have always been at war with relative imports.Alex Gaynor
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17009 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-10-17Remove several more relative imports.Alex Gaynor
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17007 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-10-16Fixed #17056 -- Tweaked insert SQL clause generation so a corner case ↵Ramiro Morales
doesn't fail with Oracle. git-svn-id: http://code.djangoproject.com/svn/django/trunk@16997 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-09-10Remove a bunch of deadcode/dead imports.Alex Gaynor
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16794 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-09-10Fixed bulk_insertion on databases which don't yet support it. Thanks to ↵Alex Gaynor
Justin Bronn for his Oracle wizardry. git-svn-id: http://code.djangoproject.com/svn/django/trunk@16793 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-09-09Fixed #7596. Added Model.objects.bulk_create, and make use of it in several ↵Alex Gaynor
places. This provides a performance benefit when inserting multiple objects. THanks to Russ for the review, and Simon Meers for the MySQl implementation. git-svn-id: http://code.djangoproject.com/svn/django/trunk@16739 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-08-23Allow "pk" as a field alias in QuerySet.only() calls.Malcolm Tredinnick
Thanks to GDorn for the patch. Fixed #15494. git-svn-id: http://code.djangoproject.com/svn/django/trunk@16668 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-08-23Added convenience method for viewing Query SQL without params.Malcolm Tredinnick
This is the old Query.as_sql() method revived: it's like Query.__str__, but the parameters aren't substituted into the placeholders. Thus, it's a more accurate representation of the SQL the (default) backend will see. Entirely internal. git-svn-id: http://code.djangoproject.com/svn/django/trunk@16655 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-08-22Fixed #14876 -- Ensure that join promotion works correctly when there are ↵Russell Keith-Magee
nullable related fields. Thanks to simonpercivall for the report, oinopion and Aleksandra Sendecka for the original patch, and to Malcolm for helping me wrestle the edge cases to the ground. git-svn-id: http://code.djangoproject.com/svn/django/trunk@16648 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-07-13Fixed #16225 -- Removed unused imports. Many thanks to Aymeric Augustin for ↵Jannis Leidel
the work on the patch and Alex for reviewing. git-svn-id: http://code.djangoproject.com/svn/django/trunk@16539 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-07-07Fixed #16409 -- Fixed an error condition when using QuerySet only()/defer() ↵Ramiro Morales
on the result of an annotate() call. Thanks jaklaassen AT gmail DOT com and Tai Lee for the reports and Tai for the patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@16522 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-06-28Fixed #5535 -- Allow using an explicit foreign key in get() calls. Thanks, ↵Jannis Leidel
Michal Petrucha. git-svn-id: http://code.djangoproject.com/svn/django/trunk@16473 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-05-21Fixed #14476 -- Fixed resolution of automatically generated annotation names ↵Ramiro Morales
so e.g. filtering based on them works. Thanks dirleyls for the report and patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@16252 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-05-15Fixed #15790 -- Fixed QuerySet only() and defer() methods behavior with ↵Ramiro Morales
proxy models. Thanks Michal Modzelewzki for the report and patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@16228 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-05-07Fixed #15709 - Duplicated group_by conditionLuke Plant
Thanks to ziangsong for report, and to mk for the patch git-svn-id: http://code.djangoproject.com/svn/django/trunk@16180 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-05-05Fixed #15823 - incorrect join condition when combining Q objectsLuke Plant
Thanks to dcwatson for the excellent report and patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@16159 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-04-22Fixed #14729 -- RawQuerySet.__repr__ fails when params passed as list. ↵Jannis Leidel
Thanks, intgr for ticket and accuser for patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@16088 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-04-20Fixed #2705: added a `select_for_update()` clause to querysets.Jacob Kaplan-Moss
A number of people worked on this patch over the years -- Hawkeye, Colin Grady, KBS, sakyamuni, anih, jdemoor, and Issak Kelly. Thanks to them all, and apologies if I missed anyone. Special thanks to Dan Fairs for picking it up again at the end and seeing this through to commit. git-svn-id: http://code.djangoproject.com/svn/django/trunk@16058 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-04-11Made some negligible docstring fixes while I was poking around in the depths ↵Adrian Holovaty
of query.py git-svn-id: http://code.djangoproject.com/svn/django/trunk@16025 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-03-28Removed a bunch more Python 2.4 workarounds now that we don't support that ↵Adrian Holovaty
version. Refs #15702 -- thanks to jonash for the patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@15927 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-03-14Fixed #14733: no longer "validate" .raw() queries.Jacob Kaplan-Moss
Turns out that a lot more than just SELECT can return data, and this list is very hard to define up front in a cross-database manner. So let's just assume that anyone using raw() is at least halfway competant and can deal with the error messages if they don't use a data-returning query. Thanks to Christophe Pettus for the patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@15803 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-02-08Fixed #13815 -- Ensure that reverse exclude lookups on nullable foreign keys ↵Russell Keith-Magee
exclude null values. Thanks to bpeschier for the report and patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@15458 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-01-26Fixed #15161 - Corrected handling of ManyToManyField with through table ↵Carl Meyer
using to_field on its ForeignKeys. Thanks to adehnert for the report. git-svn-id: http://code.djangoproject.com/svn/django/trunk@15330 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-01-26Tweaked r15303 to avoid O(N) lookup of field name. Thanks to Alex's eagle eyes.Carl Meyer
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15324 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-01-26Fixed #13159 -- properly quote aggregates in order_by.Alex Gaynor
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15318 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
2011-01-14Cleaned up the ORM slightly.Alex Gaynor
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15203 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-01-11Fixed #11293 -- fixed using Q objects to generate ORs with aggregates.Alex Gaynor
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15173 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-12-22Fixed #10154: Allow combining F expressions with timedelta values.Karen Tracey
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15018 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-12-01Fixed a bug in date queries with GIS backends introduced in [14715].Alex Gaynor
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14760 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-11-26Fixed a suite of errors in the ORM -- a) fixed calling ↵Alex Gaynor
values_list().values_list() and changing whether the results are flat, b) fixed an issue with fields on the left-hand side of what becomes the HAVING clause not being included in the GROUP BY clause, and c) fixed a bug with fields from values() calls not being included in the GROUP BY clause. This fixed the recent test failures under postgresql. git-svn-id: http://code.djangoproject.com/svn/django/trunk@14715 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-11-23Fixed #14697 - speeded up model instance creation by moving work outside of ↵Luke Plant
loops Thanks to akaariai for the report and initial patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@14687 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-11-22Fixed #14754 -- corrected using an aggregate in an F expressions when that ↵Alex Gaynor
queryset is later used in a subquery. Thanks to master for the patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@14681 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-11-17Fixed #14423 -- corrected incorrect SQL being generated when a nullable, ↵Alex Gaynor
inherited field was used in an exclude. Thanks to PhiR_42 for the patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@14600 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-11-17Fixed #12687 -- fixed an issue with aggregates and counts in conjunction ↵Alex Gaynor
with annotations where the QuerySet was provably empty. git-svn-id: http://code.djangoproject.com/svn/django/trunk@14586 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-11-09Fixed #7539, #13067 -- Added on_delete argument to ForeignKey to control ↵Carl Meyer
cascade behavior. Also refactored deletion for efficiency and code clarity. Many thanks to Johannes Dollinger and Michael Glassford for extensive work on the patch, and to Alex Gaynor, Russell Keith-Magee, and Jacob Kaplan-Moss for review. git-svn-id: http://code.djangoproject.com/svn/django/trunk@14507 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-11-04Fixed a test failure introduced in [14461].Alex Gaynor
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14462 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-11-04Fixed #13935, added support for using QuerySet.dates across related fields. ↵Alex Gaynor
Thanks to valyagolev for his work on the patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@14461 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-10-13Fixed #12192 -- Don't execute any DB query when the QS slicing being performedRamiro Morales
will result in use of LIMIT 0. Thanks Suor for the report. git-svn-id: http://code.djangoproject.com/svn/django/trunk@14204 bcc190cf-cafb-0310-a4f2-bffc1f526a37