Commit Graph

1303 Commits

Author SHA1 Message Date
Andrew Godwin 8ba5bf3198 Very start of schema alteration port. Create/delete model and some tests. 2012-06-18 17:34:36 +01:00
Anssi Kääriäinen 86c20e39eb Fixed connection.queries encoding handling on Oracle
In addition, removed a possibly problematic .filter() call from
backends.test_query_encoding test. It is possible the .filter could
cause collation problems on MySQL, and as it wasn't absolutely needed
for the test it seemed better to get rid of the call.

Refs #18461.
2012-06-13 14:16:34 +03:00
Claude Paroz e9ef9776d1 Fixed #18461 -- Ensured that last_executed_query returns Unicode
Thanks Anssi Kääriäinen for the review.
2012-06-13 12:04:46 +02:00
Claude Paroz 3dd5d726d1 Fixed #18463 -- Forced type() argument to be a byte string 2012-06-11 22:14:06 +02:00
Claude Paroz aa423575e7 Fixed #17760 -- Implemented callable database features as cached properties
This does remove the requirement to call features.confirm() method
before checking the properties.
Thanks cdestiger and Ramiro Morales for their work on the patch.
2012-06-09 15:59:52 +02:00
Jann Kleen 1a412dda62 Fixed #18432 -- Prevented the ForeignKey field from creating an invalid query when chained. Thanks, Jann Kleen. 2012-06-07 18:49:19 +02:00
Claude Paroz 4a103086d5 Fixed #18269 -- Applied unicode_literals for Python 3 compatibility.
Thanks Vinay Sajip for the support of his django3 branch and
Jannis Leidel for the review.
2012-06-07 18:08:47 +02:00
Luke Plant f5ce1793a8 Small cleanup in prefetch_related code 2012-06-06 14:19:06 +01:00
Luke Plant 4fea46a030 Fixed #18309 - Prefetch related does not work for fkey to multitable inherited model
Thanks to milosu for the report, tests and initial patch.
2012-06-06 14:17:32 +01:00
Aymeric Augustin 939af5a654 Fixed a typo in a comment. Refs #17742. 2012-06-01 08:09:58 +02:00
Claude Paroz 0dc904979d Fixed #18407 -- Made model field's to_python methods fully accept unicode.
When generating error message in to_python, any unicode string
containing non-ascii characters triggered a UnicodeEncodeError for
most field types.
2012-05-31 16:46:07 +02:00
Michael Newman 4423757c0c Fixed #18135 -- Close connection used for db version checking
On MySQL when checking the server version, a new connection could be
created but never closed. This could result in open connections on
server startup.
2012-05-27 18:45:08 +03:00
Anssi Kääriäinen a8a81aae20 Fixed #18343 -- Cleaned up deferred model implementation
Generic cleanup and dead code removal in deferred model field loading
and model.__reduce__().

Also fixed an issue where if an inherited model with a parent field
chain parent_ptr_id -> id would be deferred loaded, then accessing
the id field caused caused a database query, even if the id field's
value is already loaded in the parent_ptr_id field.
2012-05-27 18:11:13 +03:00
Anssi Kääriäinen 8c72aa2379 Fixed qs.order_by() join promotion for already existing joins
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-24 18:42:06 +03:00
Aymeric Augustin 1e6c3368f2 Fixed #18177 -- Cached known related instances.
This was recently fixed for one-to-one relations; this patch adds
support for foreign keys. Thanks kaiser.yann for the report and
the initial version of the patch.
2012-05-24 13:25:01 +02:00
Anssi Kääriäinen 0df4593f0e Fixed #18319 -- Added 'supports_sequence_reset' DB feature
Added a new feature to allow 3rd party backends to skip tests which
test sequence resetting.

Thanks to manfre for report and patch.
2012-05-22 23:51:05 +03:00
Claude Paroz df7a65ac4b Replaced 'next' testing by collections.Iterator testing.
The new construct is also Python 3 compatible (where 'next' has
been renamed to '__next__').
2012-05-22 20:37:38 +02:00
Anssi Kääriäinen d5c7f9efc3 Fixed #18304 -- Optimized save() when update_can_self_select=False
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-22 20:59:33 +03:00
Claude Paroz 38408f8007 Marked bytestrings with b prefix. Refs #18269
This is a preparation for unicode literals general usage in
Django (Python 3 compatibility).
2012-05-19 17:43:34 +02:00
Claude Paroz 7549de841c Fixed #18334 -- Fixed detection of supports_stddev backend feature.
Thanks to Michael Manfre for the report and Anssi Kääriäinen for the
review.
2012-05-18 12:12:45 +02:00
Aymeric Augustin dcd4383107 Fixed #9893 -- Validated the length of file names
after the full file name is generated by the storage class.

Thanks Refefer for the report, carsongee for the patch, and
everyone else involved in the discussion.
2012-05-17 16:02:05 +02:00
Andrei Antoukh 365853da01 Fixed #4102 -- Allow update of specific fields in model.save()
Added the ability to update only part of the model's fields in
model.save() by introducing a new kwarg "update_fields". Thanks
to all the numerous reviewers and commenters in the ticket
2012-05-12 10:29:41 +03:00
Claude Paroz 169b1a404c Replaced foo.next() by next(foo).
This new syntax for next() has been introduced in Python 2.6 and is
compatible with Python 3.
2012-05-10 20:15:49 +02:00
Anssi Kääriäinen c2e1ecb4b1 Fix proxy model Query.remove_inherited_models()
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-09 20:33:31 +03:00
Simon Charette 5cbfb48b92 Made model fields comparable to other objects
Fixed #17851 -- Added __lt__ and @total_ordering to models.Field,
made sure these work correctly on other objects than Field, too.
2012-05-07 20:08:20 +03:00
Claude Paroz 1aae1cba99 Imported zip from future_builtins instead of itertools.izip.
In Python 3, itertools.izip is not available any more (behaviour
integrated in standard zip).
2012-05-07 17:25:12 +02:00
Aymeric Augustin 46b082e05c Fixed #17742 -- Handled aware datetimes in DateField
Converted aware datetimes to the default time zone before using them
in the context of a DateField.
2012-05-01 11:29:55 +02:00
Claude Paroz 596cb9c7e2 Replaced print statement by print function (forward compatibility syntax). 2012-04-30 20:45:03 +02:00
Anssi Kääriäinen a18e43c5bb Made get_indexes() consistent across backends.
Fixed #15933, #18082 -- the get_indexes() method introspection was
done inconsitently depending on the backend. For example SQLite
included all the columns in the table in the returned dictionary,
while MySQL introspected also multicolumn indexes.

All backends return now consistenly only single-column indexes.

Thanks to andi for the MySQL report, and ikelly for comments on
Oracle's get_indexes() changes.
2012-04-30 14:30:29 +03:00
Alex Gaynor d5a277ba4d Switch a datastructure internal to the ORM to be a set, instead of a dictionary. 2012-04-29 22:18:30 -04:00
Adrian Holovaty 6ff118cdb9 Fixed #17644 -- Changed Query.alias_map to use namedtuples
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-29 17:50:48 -05:00
Claude Paroz 3904b74a3f Fixed #18013 -- Use the new 'as' syntax for exceptions.
Thanks Clueless for the initial patch.
Note that unittest has been purposely left out (external package only used by Python 2.6).
2012-04-29 20:57:15 +02:00
Anssi Kääriäinen 76c3314b6d Removed unused variable from sql/query.py 2012-04-29 21:23:38 +03:00
Anssi Kääriäinen 584e2c0337 Prevent Oracle from changing field.null to True
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-29 19:25:46 +03:00
Anssi Kääriäinen 5aa51fa999 Simplified QuerySet field.null handling
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-29 16:27:25 +03:00
Anssi Kääriäinen 527cce80dc Made table_names() output sorted.
Fixed #18218 -- previously Django's introspection table_names() and
get_table_list() methods did not sort the output consistently. This
resulted in random order of inspected models.

This commit also removed all external usages of get_table_list().
table_names() should be used instead.

Thanks to claudep for patch and report.
2012-04-29 02:11:55 +03:00
Anssi Kääriäinen c4e62eff90 Fixed #17653 -- Changed MySQL backend to raise a ValueError if zero is used as an AutoField value.
Thanks to Sylvain Lebon for the report, krzysiumed for the patch and charettes and claudep for reviews.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@17933 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2012-04-24 18:03:14 +00:00
Anssi Kääriäinen 612247b3a0 Fixed #16961 -- Skipped resetting AUTO_INCREMENT fields for MySQL if the server version is greater than 5.0.12. This allows for much faster testing.
Thanks to aigarius for the report and claudep and ramiro for review.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@17932 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2012-04-24 16:47:31 +00:00
Alex Gaynor 3c5ff9d703 Fixed #5893 -- Added a flag to FilePathField to allow listing folders, in addition to regular files. Thank you to Brian Rosner, for encouraging me to first contribute to Django 4 years ago.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17925 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2012-04-22 14:44:08 +00:00
Ramiro Morales 4536359887 Fixed #18116 -- Raised minimum MySQL version officially suported to 5.0.3.
Thanks Carl, Claude and Anssi for discussion and patch review.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17921 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2012-04-21 03:04:10 +00:00
Anssi Kääriäinen 53fb45c6d8 Fixed #17615 -- Corrected unique field validation when using multitable inheritance. The validation used wrong pk value if the parent and child model had different pk fields. Thanks ungenio for the report and patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17920 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2012-04-20 17:34:29 +00:00
Anssi Kääriäinen d5b93d3281 Fixed #10494 -- Added kwargs to QuerySet.get() error message in the case no objects were found.
Thanks brondsem for the report, Szymon Pyzalski for the patch and oinopion for review.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@17917 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2012-04-20 11:09:32 +00:00
Claude Paroz 2cd516002d Fixed #18002 -- Fixed typo in attribute name in ReverseSingleRelatedObjectDescriptor.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17904 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2012-04-12 20:23:41 +00:00
Aymeric Augustin 632b6a1a73 Fixed #17439 -- Prevented spurious queries for missing objects after prefetch_related has run.
That affects nullable foreign key, nullable one-to-one, and reverse one-to-one relations.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@17899 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2012-04-11 21:11:22 +00:00
Aymeric Augustin b90d4e5b74 Made the caching of related and reverse related objects consistent in OneToOneFields. Fixed #13839. Refs #17439.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17890 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2012-04-10 12:29:25 +00:00
Aymeric Augustin 1f11069aa5 Fixed #18090 -- Applied filters when running prefetch_related backwards through a one-to-one relation.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17888 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2012-04-10 06:04:53 +00:00
Carl Meyer f195f1ed24 Fixed #18083 -- Fixed cascade deletion with proxy model of concrete subclass. Thanks Simon Charette for report and patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17887 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2012-04-09 22:41:20 +00:00
Julien Phalip 93d1fdb130 Fixed #17877 -- Ensured that extra WHERE clauses get correctly ANDed when 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-09 00:43:08 +00:00
Anssi Kääriäinen 4f62352412 Fixed #18014 -- Removed rev_join_map from sql/query.py.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17878 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2012-04-08 12:29:05 +00:00
Claude Paroz 4b3fd424f4 Fixed #15782 -- Prevented MySQL backend to crash on runserver when db server is down. Thanks toofishes for the report and patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17868 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2012-04-02 20:29:50 +00:00