Commit Graph

1479 Commits

Author SHA1 Message Date
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
Anssi Kääriäinen 1893467784 Fixed #19274 -- Made db connection creation overridable in subclasses
Connection creation was done in db backend ._cursor() call. This
included taking a new connection if needed, initializing the session
state for the new connection and finally creating the connection.

To allow easier modifying of these steps in subclasses (for example to
support connection pools) the _cursor() now calls get_new_connection()
and init_connection_state() if there isn't an existing connection. This
was done for all non-gis core backends. In addition the parameters used
for taking a connection are now created by get_connection_params().

We should also do the same for gis backends and encourage 3rd party
backends to use the same pattern. The pattern is not enforced in code,
and as the backends are private API this will not be required by
documentation either.
2012-11-27 19:47:19 +02:00
Aymeric Augustin 2ea80b94d7 Fixed #19362 -- Detected invalid use of @python_2_unicode_compatible.
Thanks m3wolf for the report and akaariai for reproducing the problem.
2012-11-27 09:45:37 +01:00
Anssi Kääriäinen 08b4a22293 Updated stale docstring of setup_joins 2012-11-24 16:26:05 +02:00
Russell Keith-Magee c8985a8a73 Fixed #19806 -- Ensure that content types and permissions aren't created for swapped models.
Thanks to rizumu for the report.
2012-11-24 13:43:20 +08:00
Anssi Kääriäinen 0a0a0d66b3 Fixed #19351 -- SQLite bulk_insert of more than 500 single-field objs 2012-11-24 01:13:12 +02:00
Anssi Kääriäinen a27582484c Fixed SQLite's collapsing of same-valued instances in bulk_create
SQLite used INSERT INTO tbl SELECT %s UNION SELECT %s, the problem
was that there should have been UNION ALL instead of UNION.

Refs #19351
2012-11-24 01:12:17 +02:00
Anssi Kääriäinen 90b86291d0 Fixed #18375 -- Removed dict-ordering dependency for F-expressions
F() expressions reuse joins like any lookup in a .filter() call -
reuse multijoins generated in the same .filter() call else generate
new joins. Also, lookups can now reuse joins generated by F().

This change is backwards incompatible, but it is required to prevent
dict randomization from generating different queries depending on
.filter() kwarg ordering. The new way is also more consistent in how
joins are reused.
2012-11-23 19:53:04 +02:00
Claude Paroz 8c69278764 Fixed #18989 -- Removed unused condition in CursorWrapper
Thanks zimnyx for the report.
2012-11-17 16:34:14 +01:00
Anssi Kääriäinen 1194a96999 Fixed a regression in select_related
The regression was caused by the fix for #13781 (commit
f51e409a5f). Reason was leaving
off some crucial lines when resolving a merge conflict.
2012-11-15 20:17:57 +02:00
Anssi Kääriäinen f51e409a5f Fixed #13781 -- Improved select_related in inheritance situations
The select_related code got confused when it needed to travel a
reverse relation to a model which had different parent than the
originally travelled relation.

Thanks to Trac aliases shauncutts for report and ungenio for original
patch (committed patch is somewhat modified version of that).
2012-11-15 17:15:21 +02:00
Anssi Kääriäinen 92d7f541da Fixed #19058 -- Fixed Oracle GIS crash
The problem is the same as in #10888 which was reintroduced when
bulk_insert was added. Thanks to Jani Tiainen for report, patch and
also testing the final patch on Oracle GIS.
2012-11-15 16:08:06 +02:00
Anssi Kääriäinen ebcf6b36ff Fixed select_related performance regressions
The regression was caused by select_related fix for Oracle, commit
c159d9cec0.
2012-11-13 22:52:58 +02:00