summaryrefslogtreecommitdiff
path: root/django/db/models/sql
AgeCommit message (Collapse)Author
2012-05-22Fixed #18304 -- Optimized save() when update_can_self_select=FalseAnssi Kääriäinen
Databases with update_can_self_select = False (MySQL for example) generated non-necessary queries when saving a multitable inherited model, and when the save resulted in update.
2012-05-10Replaced foo.next() by next(foo).Claude Paroz
This new syntax for next() has been introduced in Python 2.6 and is compatible with Python 3.
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-05-07Imported zip from future_builtins instead of itertools.izip.Claude Paroz
In Python 3, itertools.izip is not available any more (behaviour integrated in standard zip).
2012-04-29Switch a datastructure internal to the ORM to be a set, instead of a dictionary.Alex Gaynor
2012-04-29Fixed #17644 -- Changed Query.alias_map to use namedtuplesAdrian Holovaty
This makes the code easier to understand and may even have a benefit in memory usage (namedtuples instead of dicts). Thanks, lrekucki and akaariai
2012-04-29Fixed #18013 -- Use the new 'as' syntax for exceptions.Claude Paroz
Thanks Clueless for the initial patch. Note that unittest has been purposely left out (external package only used by Python 2.6).
2012-04-29Removed unused variable from sql/query.pyAnssi Kääriäinen
2012-04-29Prevent Oracle from changing field.null to TrueAnssi Kääriäinen
Fixed #17957 -- when using Oracle and character fields, the fields were set null = True to ease the handling of empty strings. This caused problems when using multiple databases from different vendors, or when the character field happened to be also a primary key. The handling was changed so that NOT NULL is not emitted on Oracle even if field.null = False, and field.null is not touched otherwise. Thanks to bhuztez for the report, ramiro for triaging & comments, ikelly for the patch and alex for reviewing.
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.
2012-04-09Fixed #17877 -- Ensured that extra WHERE clauses get correctly ANDed when ↵Julien Phalip
they contain OR operations. Thanks to Marek Brzóska for the report, to eleather for the test case and to Adrien Lemaire for the patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@17880 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2012-04-08Fixed #18014 -- Removed rev_join_map from sql/query.py.Anssi Kääriäinen
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17878 bcc190cf-cafb-0310-a4f2-bffc1f526a37
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