Commit Graph

1491 Commits

Author SHA1 Message Date
Simon Charette fb606e10ac Fixed #19653 -- Removed `Manager.get_empty_query_set`. 2013-02-04 04:02:50 -05:00
Claude Paroz 3c0a81aaf0 Fixed #19709 -- Fixed TimeField introspection on MySQL
Thanks Eugene Grachev for the report.
2013-01-31 20:41:57 +01:00
Tim Graham ee26797cff Fixed typos in docs and comments 2013-01-29 10:55:55 -07:00
Aymeric Augustin f46d7314b5 Fixed #19677 -- Introspection of recursive foreign keys under SQLite.
Thanks Simon Charette.
2013-01-28 10:17:56 +01:00
Aymeric Augustin 6605ac331a Fixed #17158 -- Used a non-ambiguous representation of SQL queries
when a correct representation cannot be obtained.
2013-01-26 17:51:44 +01:00
Marc Tamlyn 389892aae5 Remove dup_select_related method.
This undocumented method was used in an old version of the admin, is
totally untested and hails from 2008. Although it's listed in the
"public methods" section, as it's not documented or used I don't think
it needs a deprecation path.

If we think it's useful I'll write some tests/docs for it instead...
2013-01-23 00:26:20 +00:00
Nick Sandford fe54377dae Fixed #17813 -- Added a .earliest() method to QuerySet
Thanks a lot to everybody participating in developing this feature.
The patch was developed by multiple people, at least Trac aliases
tonnzor, jimmysong, Fandekasp and slurms.

Stylistic changes added by committer.
2013-01-20 06:39:35 +02:00
Jani Tiainen d194f29057 Fixed #19606 -- Adjusted cx_Oracle unicode detection. 2013-01-19 09:27:16 +02:00
Anssi Kääriäinen 56f34f9f22 Removed models/related.py BoundRelatedObject
The class wasn't used anywhere except in RelatedObject.bind(), which
wasn't used anywhere. The class had one method defined as
NotImplemented, yet the class wasn't subclassed anywhere. In short, the
class was dead code.
2013-01-18 16:00:57 +02:00
Anssi Kääriäinen 3647c0a49a Avoided unnecessary recreation of RelatedObjects
Refs #19399. Thanks to Track alias KJ for the patch.
2013-01-18 07:09:39 +02:00
David Cramer abbb88886b Move logic seperation as its not longer repetitive 2013-01-14 13:17:01 -08:00
David Cramer 272de9eb6b Send post_delete signals immediately
In a normal relational construct, if you're listening for an event
that signals a child was deleted, you dont expect that the parent
was deleted already.

This change ensures that post_delete signals are fired immediately
after objects are deleted in the graph.
2013-01-14 13:15:47 -08:00
Claude Paroz 0171ba65db Fixed #17574 -- Implemented missing get_key_columns in PostgreSQL backend 2013-01-12 21:46:08 +01:00
Claude Paroz 223fc8eaf9 Return namedtuple from get_table_description
We don't make use of it currently to not break third-party db
backends.
2013-01-12 21:14:22 +01:00
Alex Gaynor a170c3f755 Removed some now dead code from deletion (thanks to Carl Meyer for noticing it). 2013-01-11 20:59:29 -08:00
Nick Sandford eb6c107624 Fixed #19360 -- Raised an explicit exception for aggregates on date/time fields in sqlite3
Thanks lsaffre for the report and Chris Medrela for the initial
patch.
2013-01-11 18:10:28 +01:00
Simon Charette f58efd07ff Fixed #19576 -- Use `six.with_metaclass` uniformously accross code base. 2013-01-08 20:13:43 +01:00
Anssi Kääriäinen 55da775ce1 Fixed #17541 -- Fixed non-saved/nullable fk querying 2013-01-08 21:02:38 +02:00
Anssi Kääriäinen 23ca3a0194 Fixed #16759 -- Remove use of __deepcopy__ in qs.clone()
The original problem was that queryset cloning was really expensive
when filtering with F() clauses. The __deepcopy__ went too deep copying
_meta attributes of the models used. To fix this the use of
__deepcopy__ in qs cloning was removed.

This commit results in some speed improvements across the djangobench
benchmark suite. Most query_* tests are 20-30% faster, save() is 50%
faster and finally complex filtering situations can see 2x to order
of magnitude improvments.

Thanks to Suor, Alex and lrekucki for valuable feedback.
2013-01-08 19:17:13 +02:00
Claude Paroz c698c55966 Created special PostgreSQL text indexes when unique is True
Refs #19441.
2013-01-07 17:54:30 +01:00
Anssi Kääriäinen a2396a4c8f Fixed #19173 -- Made EmptyQuerySet a marker class only
The guarantee that no queries will be made when accessing results is
done by new EmptyWhere class which is used for query.where and having.

Thanks to Simon Charette for reviewing and valuable suggestions.
2013-01-06 19:18:28 +02:00
Claude Paroz b740da3504 Fixed #19192 -- Allowed running tests with dummy db backend
Thanks Simon Charette for the initial patch, and Jan Bednařík for
his work on the ticket.
2013-01-04 13:55:20 +01:00
mpaolini 6248833d9e Added documentation for the 'db' argument of the post-syncdb signal. 2013-01-03 22:04:55 +01:00
Aymeric Augustin a051a9d929 Fixed PR 478 -- Removed superfluous try/except block. 2013-01-02 22:46:36 +01:00
Aymeric Augustin 07fbc6ae0e Fixed #19547 -- Caching of related instances.
When &'ing or |'ing querysets, wrong values could be cached, and crashes
could happen.

Thanks Marc Tamlyn for figuring out the problem and writing the patch.
2013-01-02 22:21:46 +01:00
Anssi Kääriäinen ce3c71faf1 Minor improvement to proxy model handling
Refs #19385
2012-12-30 11:20:27 +02:00
Anssi Kääriäinen 807eff7439 Made use of PathInfo.direct flag in trim_joins
Refs #19385
2012-12-30 11:20:13 +02:00
Anssi Kääriäinen 68985db482 Added Query.join_parent_model()
This simplifies especially compiler.py a lot, where almost the same
code was repeated multiple times.

Refs #19385
2012-12-30 11:19:35 +02:00
Anssi Kääriäinen 4511aeb6b8 Moved join path generation to Field
Refs #19385
2012-12-30 11:19:19 +02:00
Anssi Kääriäinen 9ef3cab40b Made sure join_field is always available in .join()
Refs #19385
2012-12-30 11:18:25 +02:00
Aymeric Augustin ef017a5f00 Advanced pending deprecation warnings.
Also added stacklevel argument, fixed #18127.
2012-12-29 21:59:07 +01:00
Aymeric Augustin e9c24bef74 Fix #19524 -- Incorrect caching of parents of unsaved model instances.
Thanks qcwxezdas for the report. Refs #13839.
2012-12-28 23:34:54 +01:00
Aymeric Augustin db278c3bf9 Fixed #19525 -- Reverted dcd4383107 and 05d333ba3b.
Refs #9893, #18515.

Thanks Russell for the report.
2012-12-27 09:37:57 +01:00
Anssi Kääriäinen 4007c8f6eb Fixed a regression in distinct_on
Caused by regression fix for #19500.
2012-12-20 22:50:06 +02:00
Anssi Kääriäinen d407164c04 Fixed #18854 -- Join promotion in disjunction cases
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-20 21:45:15 +02:00
Anssi Kääriäinen 3dcd435a0e Fixed #19500 -- Solved a regression in join reuse
The ORM didn't reuse joins for direct foreign key traversals when using
chained filters. For example:
    qs.filter(fk__somefield=1).filter(fk__somefield=2))
produced two joins.

As a bonus, reverse onetoone filters can now reuse joins correctly

The regression was caused by the join() method refactor in commit
68847135bc

Thanks for Simon Charette for spotting some issues with the first draft
of the patch.
2012-12-20 21:27:00 +02:00
Russell Keith-Magee c04c03daa3 Fixed #19401 -- Ensure that swappable model references are case insensitive.
This is necessary because get_model() checks are case insensitive, and if the swapable check isn't, the
swappable logic gets tied up in knots with models that are partially swapped out.

Thanks to chris@cogdon.org for the report and extensive analysis, and Preston for his work on the draft patch.
2012-12-20 16:10:19 +08:00
Claude Paroz 55972ee5c7 Fixed #19441 -- Created PostgreSQL varchar index when unique=True
Thanks Dylan Verheul for the report and Anssi Kääriäinen for the
review.
2012-12-18 09:56:30 +01:00
Anssi Kääriäinen c64b57d166 Replaced '__' with LOOKUP_SEP in sql/query.py
Thanks to Simon Charette for report.
2012-12-17 21:15:01 +02:00
Anssi Kääriäinen 12a96bfa26 Fixed #19197 -- fixed convert_values() for nullable numeric fields
Cleaned up the implementation of base convert_values() a little, and
made sure it accepts None as a value for numeric fields.

There are no tests attached. The reason is that not all of the
convert_values() accept None as a value for numeric fields (for example
sqlite3.convert_values()).

The reason the base convert_values() needs to accept None is that this
situation might arise in custom compilers for 3rd party backends. It
is easy to keep the convert_values() working, so lets do that.
2012-12-16 23:26:16 +02:00
Anssi Kääriäinen 704ee33f50 Fixed #16679 -- Use caching to speed up signal sending 2012-12-16 21:46:02 +02:00
Anssi Kääriäinen 69597e5bcc Fixed #10790 -- Refactored sql.Query.setup_joins()
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-12-16 17:23:26 +02:00
Anssi Kääriäinen f811649710 Fixed #18816 -- Removed "trim" argument from add_filter()
The trim argument was used by split_exclude() only to trim the last
join from the given lookup. It is cleaner to just trim the last part
from the lookup in split_exclude() directly so that there is no need
to burden add_filter() with the logic needed for only split_exclude().
2012-12-16 16:56:28 +02:00
Anssi Kääriäinen d7b49f5b0d Fixed #19469 -- Removed opts.get_ordered_objects() and related code
The code was dead-code since 2006.
2012-12-16 16:22:09 +02:00
Aymeric Augustin a001f3c31e Fixed #2304 -- Documented TRANSACTIONS_MANAGED. 2012-12-14 21:15:48 +01:00
Claude Paroz c91667338a Fixed #19357 -- Allow non-ASCII chars in filesystem paths
Thanks kujiu for the report and Aymeric Augustin for the review.
2012-12-08 11:13:52 +01:00
orblivion 0ff1d4fa49 Typeo in ValuesQuerySet._as_sql docstring 2012-12-01 18:55:26 -08:00
Tai Lee 6ebf115206 Fixed #14694 -- Made ``defer()`` work with reverse relations
Reverse o2o fields are now usable with defer.
2012-11-28 18:17:10 +02:00
Anssi Kääriäinen d37483c533 Removed duplicate opts.pk_index() method 2012-11-27 21:54:46 +02:00
Anssi Kääriäinen 905ea9619b Made sure global settings are changed in test db creation
There was an assumption that changing connection.settings_dict changed
also the settings.DATABASES values. This assumption is now gone.
2012-11-27 19:47:20 +02:00