Commit Graph

899 Commits

Author SHA1 Message Date
Andrew Godwin 7970d97a70 Docs tweaks (thanks timgraham) 2013-08-10 20:00:12 +01:00
Andrew Godwin f093646bfc Remove pointless comment. 2013-08-09 17:47:13 +01:00
Andrew Godwin ae96ad872f Remove pointless fetch_results param 2013-08-09 17:42:56 +01:00
Andrew Godwin fb16ee5a31 Remove commented-out print 2013-08-09 17:41:39 +01:00
Andrew Godwin de64c4d6e9 Merge remote-tracking branch 'core/master' into schema-alteration
Conflicts:
	django/core/management/commands/flush.py
	django/core/management/commands/syncdb.py
	django/db/models/loading.py
	docs/internals/deprecation.txt
	docs/ref/django-admin.txt
	docs/releases/1.7.txt
2013-08-09 14:17:30 +01:00
Tim Graham aa830009de Fixed #17519 -- Fixed missing SQL constraints to proxy models.
Thanks thibaultj for the report, jenh for the patch,
and charettes for the tests.
2013-08-02 07:41:56 -04:00
Andrew Godwin 12e9804d16 Rename allow_syncdb to allow_migrate 2013-07-30 12:08:59 +01:00
Andrew Godwin 68e0a169c4 Rename pre_ and post_syncdb to *_migrate, with aliases from old names 2013-07-30 11:52:52 +01:00
Shai Berger 6ed579e7eb Fixed #20785 -- Corrected exception caught for Oracle LIKE operator detection
The code that tests to see which LIKE expressions to use now runs
using non-error-wrapped cursor, so cx_Oracle exceptions need to be caught
rather than Django DatabaseErrors.

Thanks Trac user ludo for report and initial patch.
2013-07-30 03:21:06 +03:00
Claude Paroz fdd7a355bf Deprecated django.utils.importlib
This was a shim for pre-Python 2.7 support.
2013-07-29 17:10:22 +02:00
Julien Phalip 47c755327b Fixed a number of minor misspellings. 2013-07-27 18:46:03 -07:00
Andrew Godwin 9c6d57ef5a Prettier imports 2013-07-26 16:40:27 +01:00
Andrew Godwin 03ec3219a0 Merge branch 'master' into schema-alteration
Conflicts:
	django/db/backends/mysql/introspection.py
	django/db/backends/oracle/creation.py
	django/db/backends/postgresql_psycopg2/creation.py
	django/db/models/base.py
	django/db/models/loading.py
2013-07-22 19:04:25 +01:00
Shai Berger c0a4894dca Fixed last_executed_query test failure on Oracle 2013-07-08 23:47:02 +03:00
Alex Gaynor 43073dbd76 fixed a mis-importt in mysql/base.py 2013-07-08 11:18:06 +10:00
Alex Gaynor 03d9566e0d A large number of stylistic cleanups across django/db/ 2013-07-08 10:39:54 +10:00
Alex Gaynor 626fa28878 Fixed #13813 -- Comparison of DatabaseWrappers doesn't raise errors.
Patch from Lukasz Balcerzak.
2013-07-08 09:35:08 +10:00
Andrew Godwin 3a6580e485 Make get_constraints return columns in order 2013-07-02 18:02:20 +01:00
Andrew Godwin dbd3e775c1 Fix get_constraints to do multi-column indexes properly on pg 2013-07-02 12:06:00 +01:00
Andrew Godwin f343cbf06c Fix combined alters on PostgreSQL 2013-07-02 11:51:18 +01:00
Andrew Godwin 6a8cfbf07b Support for index_together in schema backends 2013-07-02 11:43:44 +01:00
Andrew Godwin b1e0ec06f0 Merge branch 'master' into schema-alteration 2013-07-02 10:49:53 +01:00
Aymeric Augustin d5589b4cd3 Removed some conditional code only needed under Python 2.6. 2013-07-01 12:02:17 +02:00
Aymeric Augustin dd9c6bc359 Introduced getters for connection.autocommit and .needs_rollback.
They ensure that the attributes aren't accessed in conditions where they
don't contain a valid value.

Fixed #20666.
2013-06-30 15:57:00 +02:00
Aymeric Augustin acd7b34aaf Advanced deprecation warnings for Django 1.7. 2013-06-29 18:49:37 +02:00
Claude Paroz 59b0c48ce2 Fixed #18592 -- Prevented crash when accessing MySQL _last_executed
Thanks reames at asymmetricventures.com for the report.
2013-06-29 18:44:41 +02:00
Andrew Godwin 7a47ba6f6a Merge remote-tracking branch 'core/master' into schema-alteration
Conflicts:
	django/db/backends/__init__.py
	django/db/models/fields/related.py
	tests/field_deconstruction/tests.py
2013-06-28 17:32:57 +01:00
Shai Berger d097417025 Support 'pyformat' style parameters in raw queries, Refs #10070
Add support for Oracle, fix an issue with the repr of RawQuerySet,
add tests and documentations. Also added a 'supports_paramstyle_pyformat'
database feature, True by default, False for SQLite.

Thanks Donald Stufft for review of documentation.
2013-06-28 06:59:10 +03:00
Aymeric Augustin c1284c3d3c Fixed #20571 -- Added an API to control connection.needs_rollback.
This is useful:
- to force a rollback on the exit of an atomic block without having to
  raise and catch an exception;
- to prevent a rollback after handling an exception manually.
2013-06-27 22:19:54 +02:00
Loic Bistuer a9ea7d8c70 Fixed #20462 - Replaced the str() cast introduced in 273dc55 by force_text() 2013-06-26 21:30:58 +07:00
Andrew Clark 273dc550a4 Fixed #20462 -- null/non-string regex lookups are now consistent
Thanks to noirbizarre for the report and initial patch.
2013-06-26 08:13:26 -04:00
Gilberto Gonçalves 680b512fc1 Fixed #20587 -- Made convert_values handle None values 2013-06-22 14:05:12 +01:00
Andrew Godwin 6f667999e1 Add operation that renames tables 2013-06-20 14:54:11 +01:00
Aymeric Augustin ffcf24c9ce Removed several unused imports. 2013-06-19 17:18:40 +02:00
Andrew Godwin 2ae8a8a77d Fix test running with new apps stuff/migrate actually running migrations 2013-06-19 15:36:02 +01:00
Andrew Godwin 9daf81b94e Merge remote-tracking branch 'core/master' into schema-alteration
Conflicts:
	django/db/models/loading.py
2013-06-19 12:05:23 +01:00
Tim Graham 92c49d6f01 Revert "Fixed #20462 - Fixed sqlite regex lookups for null values and non-string fields."
This reverts commit 64041f0e6e.

lookup.tests.LookupTests.test_regex_non_string fails under Postgres.
We should also try to rewrite the test using an existing model.
2013-06-11 17:55:19 -04:00
Axel Haustant 64041f0e6e Fixed #20462 - Fixed sqlite regex lookups for null values and non-string fields. 2013-06-11 14:13:40 -04:00
Aymeric Augustin 13b7f299de Added a stealth option to flush to allow cascades.
This allows using flush on a subset of the tables without having to
manually cascade to all tables with foreign keys to the tables being
truncated, when they're known to be empty.

On databases where truncate is implemented with DELETE FROM, this
doesn't make a difference. The cascade is allowed, not mandatory.
2013-06-10 11:21:54 +02:00
Andrew Godwin 3c296382b8 Merge remote-tracking branch 'core/master' into schema-alteration
Conflicts:
	django/db/models/fields/related.py
2013-06-07 11:15:34 +01:00
Andrew Godwin d0ecefc2c9 Start adding operations that work and tests for them 2013-05-29 17:47:10 +01:00
Shai Berger 0027f13904 Fixed #20014 -- implemented get_key_columns() for Oracle
Thanks Aymeric Augustin for reporting
2013-05-27 21:12:47 +03:00
Shai Berger 5e05ec3ea6 Fixed #20501 -- failure of datetime queries with timezones under Oracle 2013-05-27 17:28:57 +03:00
Anssi Kääriäinen 37ea9f9c03 Fixed #20507 -- SubqueryConstraint alias handling
MySQL should work now, too.
2013-05-27 15:05:03 +03:00
Ramiro Morales 0fa8d43e74 Replaced `and...or...` constructs with PEP 308 conditional expressions. 2013-05-26 23:47:50 -03:00
Shai Berger dfe6ea3b1f Fixed #20012 -- test_year_lookup_edge_case fails under Oracle
Used formatted date instead of datetime object for the end of the
year range, as the datetime object loses fractions-of-seconds when
inserted into the db.
2013-05-22 01:52:15 +03:00
Shai Berger 8fd40b9ae7 Fixed #20015 -- date__startswith('2008') fails under Oracle
Removed the explicit casting of strings to dates
2013-05-22 01:52:15 +03:00
Shai Berger b6ad9998e6 Fixed #20453 -- inspectdb test failure on Oracle 2013-05-22 01:52:15 +03:00
Claude Paroz d595b61aca (Re-)moved some imports 2013-05-21 17:34:19 +02:00
Aymeric Augustin 181f2ec603 Fixed test failures with Oracle when pytz isn't installed.
Thanks Shai Berger for the report.
2013-05-19 14:38:48 +02:00
Aymeric Augustin f7467181aa Merge pull request #1160 from erikr/host-inet-postgres2
Fixed #11442 -- Postgresql backend casts all inet types to text
2013-05-19 04:57:10 -07:00
Erik Romijn 60d94c2a80 Fixed #11442 -- Postgresql backend casts all inet types to text 2013-05-19 13:28:09 +02:00
Aymeric Augustin a7e2835276 Merge pull request #1028 from manfre/patch-2
Fixed #20340 - document required return value for disable_constraint_checking
2013-05-19 04:17:08 -07:00
Shai Berger 215647c0f7 Fixed #20386 - Introspection problem on Oracle
Made introspection always return a unicode as column name on Oracle.
Thanks aaugustin for review and suggestion to use force_text().
2013-05-18 14:19:26 +03:00
Andrew Godwin 331546f6ee More conversion to a ContextManager schema_editor 2013-05-18 11:48:46 +02:00
Andrew Godwin ce5bd42259 Turn SchemaEditor into a context manager 2013-05-18 11:06:30 +02:00
Andrew Godwin cb4b0de49e Merge branch 'master' into schema-alteration 2013-05-10 12:55:30 +01:00
Andrew Godwin 104ad0504b Split out a BaseAppCache, make AppCache borg again, add _meta.app_cache 2013-05-09 15:16:43 +01:00
Aymeric Augustin 86b4ac665a [py3] Stopped iterating on exceptions. Refs #20025. 2013-05-08 13:05:23 +02:00
Aymeric Augustin e81e319f15 Fixed #20025 -- Pointed to a MySQLdb fork for Python 3.
Made a few minor compatibility adjustments.
2013-05-08 13:05:09 +02:00
Aymeric Augustin 1fff8daf88 Fixed test failures on MySQL.
Some tests failed when the time zone definitions were loaded in MySQL
and pytz wasn't installed. This setup isn't supported.
2013-05-08 13:03:36 +02:00
Michael Manfre f043cfe3e2 Fixed documentation of disable_constraint_checking
The docstring and base implementation of disable_constraint_checking do not indicate that a return value is expected for proper behavior.
2013-04-24 14:26:13 -03:00
Andrew Godwin 6e21a59402 Fix schema editor interaction with new transactions 2013-04-19 09:01:45 +01:00
Andrew Godwin 7f3678dc4c Merge branch 'master' into schema-alteration
Conflicts:
	django/db/backends/__init__.py
	django/db/backends/mysql/base.py
	django/db/backends/oracle/base.py
	django/db/backends/oracle/creation.py
	django/db/backends/postgresql_psycopg2/base.py
	django/db/backends/sqlite3/base.py
	django/db/models/fields/related.py
2013-04-18 17:16:39 +01:00
Claude Paroz 8c41bd93c2 Fixed #16737 -- Support non-ascii column names in inspectdb
Thanks moof at metamoof.net for the report.
2013-04-01 19:59:57 +02:00
Claude Paroz 51028f50b6 Fixed getting max_digits for MySQL decimal fields
Refs #5014.
2013-04-01 18:17:00 +02:00
Claude Paroz 3ff3212713 Fixed #19220 -- Prevented decimals to be displayed in scientific notation
Thanks nebstrebor for the report and antofik for the patch.
2013-03-31 22:39:01 +02:00
Claude Paroz 86b1c31689 Fixed #19954 -- Fixed MySQL _last_executed decoding
Queries can contain binary data undecodable with utf-8. In this
case, using the 'replace' errors mode when decoding seems like
an acceptable representation of the query.
Thanks Marcel Ryser for the report.
2013-03-28 20:08:37 +01:00
Anssi Kääriäinen 97774429ae Fixed #19385 again, now with real code changes
The commit of 266de5f9ae included only
tests, this time also code changes included...
2013-03-24 18:40:40 +02:00
Claude Paroz 76aecfbc4b Fixed #9055 -- Standardized behaviour of parameter escaping in db cursors
Previously, depending on the database backend or the cursor type,
you'd need to double the percent signs in the query before passing
it to cursor.execute. Now cursor.execute consistently need percent
doubling whenever params argument is not None (placeholder substitution
will happen).
Thanks Thomas Güttler for the report and Walter Doekes for his work
on the patch.
2013-03-23 17:11:10 +01:00
Aymeric Augustin 6197935152 Fixed #19968 -- Dropped support for PostgreSQL < 8.4. 2013-03-18 21:16:29 +01:00
Aymeric Augustin 93af822c00 Improved recovery when the connection is closed in an atomic block. 2013-03-13 15:17:40 +01:00
Aymeric Augustin 83a416f5e7 Made atomic usable when autocommit is off.
Thanks Anssi for haggling until I implemented this.

This change alleviates the need for atomic_if_autocommit. When
autocommit is disabled for a database, atomic will simply create and
release savepoints, and not commit anything. This honors the contract of
not doing any transaction management.

This change also makes the hack to allow using atomic within the legacy
transaction management redundant.

None of the above will work with SQLite, because of a flaw in the design
of the sqlite3 library. This is a known limitation that cannot be lifted
without unacceptable side effects eg. triggering arbitrary commits.
2013-03-13 15:17:40 +01:00
Simon Charette bc7a10299f Fixed #20010 -- Make sure `last_executed_query` contains it's associated parameters on Oracle.
Also removed some unused imports.
2013-03-11 17:30:23 -04:00
Aymeric Augustin f2f98abb95 Avoided closing the database connection within a transaction.
Refs #9437.
2013-03-11 21:08:49 +01:00
Aymeric Augustin e654180ce2 Improved the API of set_autocommit. 2013-03-11 15:10:58 +01:00
Aymeric Augustin 423c0d5e29 Added a safety net for developers messing with autocommit. 2013-03-11 15:05:04 +01:00
Aymeric Augustin 107d9b1d97 Added an option to disable the creation of savepoints in atomic. 2013-03-11 15:05:04 +01:00
Aymeric Augustin ac37ed21b3 Deprecated TransactionMiddleware and TRANSACTIONS_MANAGED.
Replaced them with per-database options, for proper multi-db support.

Also toned down the recommendation to tie transactions to HTTP requests.
Thanks Jeremy for sharing his experience.
2013-03-11 15:04:05 +01:00
Aymeric Augustin 09ba70f9f1 Made transaction management work even before the first SQL query.
Thanks Florian again.
2013-03-11 14:48:55 +01:00
Aymeric Augustin 7c46c8d5f2 Added some assertions to enforce the atomicity of atomic. 2013-03-11 14:48:55 +01:00
Aymeric Augustin d7bc4fbc94 Implemented an 'atomic' decorator and context manager.
Currently it only works in autocommit mode.

Based on @xact by Christophe Pettus.
2013-03-11 14:48:55 +01:00
Aymeric Augustin 4b31a6a9e6 Added support for savepoints in SQLite.
Technically speaking they aren't usable yet.
2013-03-11 14:48:55 +01:00
Aymeric Augustin e264f67174 Refactored implementation of savepoints.
Prepared for using savepoints within transactions in autocommit mode.
2013-03-11 14:48:55 +01:00
Aymeric Augustin 918f44e3ae Moved standard SQL for savepoints in the base backend.
These methods are only called when uses_savepoints = True anyway.
2013-03-11 14:48:54 +01:00
Aymeric Augustin 3bdc7a6a70 Deprecated transaction.is_managed().
It's synchronized with the autocommit flag.
2013-03-11 14:48:54 +01:00
Aymeric Augustin ba5138b1c0 Deprecated transaction.commit/rollback_unless_managed.
Since "unless managed" now means "if database-level autocommit",
committing or rolling back doesn't have any effect.

Restored transactional integrity in a few places that relied on
automatically-started transactions with a transitory API.
2013-03-11 14:48:54 +01:00
Aymeric Augustin 14aa563f51 Removed superfluous code now that connections use autocommit by default. 2013-03-11 14:48:54 +01:00
Aymeric Augustin 5e27debc5c Enabled database-level autocommit for all backends.
This is mostly a documentation change.

It has the same backwards-incompatibility consequences as those
described for PostgreSQL in a previous commit.
2013-03-11 14:48:54 +01:00
Aymeric Augustin cfc114e00e Removed _enter/_leave_transaction_management.
The goal is to make all databases share a common, autocommit-based,
implementation.
2013-03-11 14:48:54 +01:00
Aymeric Augustin 1617557ae3 Added BaseDatabaseWrapper.ensure_connection.
This API is useful because autocommit cannot be managed without an open
connection.
2013-03-11 14:48:54 +01:00
Aymeric Augustin 7b4815b455 Expressed the dirty flag handling logic in terms of autocommit. 2013-03-11 14:48:54 +01:00
Aymeric Augustin cd364efa00 Stopped flipping the uses_savepoints feature at runtime. 2013-03-11 14:48:54 +01:00
Aymeric Augustin af9e9386eb Enabled autocommit for PostgreSQL.
For users who didn't activate autocommit in their database options, this
is backwards-incompatible in "non-managed" aka "auto" transaction state.
This state now uses database-level autocommit instead of ORM-level
autocommit.

Also removed the uses_autocommit feature which lost its purpose.
2013-03-11 14:48:54 +01:00
Aymeric Augustin 8717b0668c Separated autocommit and isolation level handling for PostgreSQL.
Autocommit cannot be manipulated independently from an open connection.
This commit introduces a minor change in behavior: entering transaction
management forces opening a databasse connection. This shouldn't be
backwards incompatible in any practical use case.
2013-03-11 14:48:54 +01:00
Aymeric Augustin f515619494 Added an API to control database-level autocommit. 2013-03-11 14:48:53 +01:00
Aymeric Augustin 7aacde84f2 Made transaction.managed a no-op and deprecated it.
enter_transaction_management() was nearly always followed by managed().

In three places it wasn't, but they will all be refactored eventually.
The "forced" keyword argument avoids introducing behavior changes until
then.

This is mostly backwards-compatible, except, of course, for managed
itself. There's a minor difference in _enter_transaction_management:
the top self.transaction_state now contains the new 'managed' state
rather than the previous one. Django doesn't access
self.transaction_state in _enter_transaction_management.
2013-03-11 14:48:53 +01:00
Florian Apolloner 8aefd30379 Fixed BinaryField support on Oracle. 2013-03-09 23:39:14 +01:00
Aymeric Augustin 25ce177e66 Added missing method in the dummy database backend. 2013-03-07 14:53:52 +01:00
Aymeric Augustin e0449316eb Fixed #18130 -- Made the isolation level configurable on PostgreSQL.
Thanks limscoder for the report and niwi for the draft patch.
2013-03-02 15:05:49 +01:00
Aymeric Augustin d63e55039d Reordered methods in database wrappers.
* Grouped related methods together -- with banner comments :/
* Described which methods are intended to be implemented in backends.
* Added docstrings.
* Used the same order in all wrappers.
2013-03-02 13:33:17 +01:00
Claude Paroz c5a25c2771 Add introspection support for BinaryField 2013-03-02 10:29:03 +01:00
Claude Paroz 8ee1eddb7e Add a BinaryField model field
Thanks Michael Jung, Charl Botha and Florian Apolloner for review
and help on the patch.
2013-03-02 10:29:02 +01:00
Aymeric Augustin 2ee21d9f0d Implemented persistent database connections.
Thanks Anssi Kääriäinen and Karen Tracey for their inputs.
2013-02-28 15:28:13 +01:00
Aymeric Augustin 59a3520875 Refactored database exceptions wrapping.
Squashed commit of the following:

commit 2181d833ed1a2e422494738dcef311164c4e097e
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date:   Wed Feb 27 14:28:39 2013 +0100

    Fixed #15901 -- Wrapped all PEP-249 exceptions.

commit 5476a5d93c19aa2f928c497d39ce6e33f52694e2
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date:   Tue Feb 26 17:26:52 2013 +0100

    Added PEP 3134 exception chaining.

    Thanks Jacob Kaplan-Moss for the suggestion.

commit 9365fad0a650328002fb424457d675a273c95802
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date:   Tue Feb 26 17:13:49 2013 +0100

    Improved API for wrapping database errors.

    Thanks Alex Gaynor for the proposal.

commit 1b463b765f2826f73a8d9266795cd5da4f8d5e9e
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date:   Tue Feb 26 15:00:39 2013 +0100

    Removed redundant exception wrapping.

    This is now taken care of by the cursor wrapper.

commit 524bc7345a724bf526bdd2dd1bcf5ede67d6bb5c
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date:   Tue Feb 26 14:55:10 2013 +0100

    Wrapped database exceptions in the base backend.

    This covers the most common PEP-249 APIs:
    - Connection APIs: close(), commit(), rollback(), cursor()
    - Cursor APIs: callproc(), close(), execute(), executemany(),
      fetchone(), fetchmany(), fetchall(), nextset().

    Fixed #19920.

commit a66746bb5f0839f35543222787fce3b6a0d0a3ea
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date:   Tue Feb 26 14:53:34 2013 +0100

    Added a wrap_database_exception context manager and decorator.

    It re-throws backend-specific exceptions using Django's common wrappers.
2013-02-27 17:26:54 +01:00
Anssi Kääriäinen 50328f0a61 Fixed #19861 -- Transaction ._dirty flag improvement
There were a couple of errors in ._dirty flag handling:
  * It started as None, but was never reset to None.
  * The _dirty flag was sometimes used to indicate if the connection
    was inside transaction management, but this was not done
    consistently. This also meant the flag had three separate values.
  * The None value had a special meaning, causing for example inability
    to commit() on new connection unless enter/leave tx management was
    done.
  * The _dirty was tracking "connection in transaction" state, but only
    in managed transactions.
  * Some tests never reset the transaction state of the used connection.
  * And some additional less important changes.

This commit has some potential for regressions, but as the above list
shows, the current situation isn't perfect either.
2013-02-27 17:54:27 +02:00
Aymeric Augustin e76147a83a Fixed #19634 -- Added proper __hash__ methods.
Classes overriding __eq__ need a __hash__ such that equal objects have
the same hash.

Thanks akaariai for the report and regebro for the patch.
2013-02-25 23:05:20 +01:00
Tomasz Rybak d7429defe6 Add sqldropindexes to manage
Change patch from https://code.djangoproject.com/ticket/5568
to work on modern Django.
Add special case for MySQL which has different syntax for DROP INDEX.
Add unit tests for the new functionality.
2013-02-24 12:38:28 +01:00
Anssi Kääriäinen ce094e570e Fixed Oracle regression in last_executed_query() with unicode strings
The regression was likely caused by the fix in #19606 which adjusted
Oracle's unicode detection, though it seems this would have been an
issue in some configurations even before.
2013-02-23 00:27:39 +02:00
Aymeric Augustin 5488437ab6 Factored code and added a missing docstring. 2013-02-21 21:26:40 +01:00
Alex Gaynor b55cde054e Added a db_constraint option to ForeignKeys.
This controls whether or not a database level cosntraint is created. This is useful in a few specialized circumstances, but in general should not be used!
2013-02-20 11:27:32 -08:00
Alex Gaynor fd3a066ae3 This function is unused and should have been removed a few releases ago. 2013-02-19 18:05:02 -08:00
Aymeric Augustin ebabd77291 Ensured a connection is established when checking the database version.
Fixed a test broken by 21765c0a. Refs #18135.
2013-02-19 10:51:24 +01:00
Aymeric Augustin 9a3988ca5a Implemented Oracle version as a cached property. 2013-02-19 10:50:22 +01:00
Aymeric Augustin ffcfb19f47 Added required methods in BaseDatabaseWrapper.
I should have included this in 29628e0b6e.
2013-02-18 22:51:56 +01:00
Aymeric Augustin 21765c0a6c Implemented PostgreSQL version as a cached property. 2013-02-18 22:49:59 +01:00
Aymeric Augustin 7b8529d206 Removed duplicate caching of mysql_version.
The manual caching in self.server_version and the cached_property
decorator are redundant.
2013-02-18 22:13:05 +01:00
Aymeric Augustin 282b2f40cd Fixed #15119 -- Stopped pinging the MySQL server. 2013-02-18 22:12:19 +01:00
Aymeric Augustin aea98e8c53 Simplified MySQL version checking.
Django used to check the version of MySQL before handling the first
request, which required:
- opening a connection
- closing it, to avoid holding it idle until the first request.

This code isn't necessary any longer since Django dropped support for
some versions of MySQL, and other database backends don't implement a
similar dance. For consistency and maintenability, remove it.

Reverts 4423757c0c.

Closes #18135.
2013-02-18 21:46:26 +01:00
Aymeric Augustin 29628e0b6e Factored out common code in database backends. 2013-02-18 17:19:09 +01:00
Aymeric Augustin 09ca010768 Removed an unecessary function.
It was introduced by the refactoring in 5a4e63e6 and made redundant by
the refactoring in 18934677.
2013-02-18 11:38:21 +01:00
Aymeric Augustin e74e207cce Fixed #17260 -- Added time zone aware aggregation and lookups.
Thanks Carl Meyer for the review.

Squashed commit of the following:

commit 4f290bdb60
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date:   Wed Feb 13 21:21:30 2013 +0100

    Used '0:00' instead of 'UTC' which doesn't always exist in Oracle.

    Thanks Ian Kelly for the suggestion.

commit 01b6366f3c
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date:   Wed Feb 13 13:38:43 2013 +0100

    Made tzname a parameter of datetime_extract/trunc_sql.

    This is required to work around a bug in Oracle.

commit 924a144ef8
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date:   Wed Feb 13 14:47:44 2013 +0100

    Added support for parameters in SELECT clauses.

commit b4351d2890
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date:   Mon Feb 11 22:30:22 2013 +0100

    Documented backwards incompatibilities in the two previous commits.

commit 91ef84713c
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date:   Mon Feb 11 09:42:31 2013 +0100

    Used QuerySet.datetimes for the admin's date_hierarchy.

commit 0d0de288a5
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date:   Mon Feb 11 09:29:38 2013 +0100

    Used QuerySet.datetimes in date-based generic views.

commit 9c0859ff7c
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date:   Sun Feb 10 21:43:25 2013 +0100

    Implemented QuerySet.datetimes on Oracle.

commit 68ab511a4f
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date:   Sun Feb 10 21:43:14 2013 +0100

    Implemented QuerySet.datetimes on MySQL.

commit 22d52681d3
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date:   Sun Feb 10 21:42:29 2013 +0100

    Implemented QuerySet.datetimes on SQLite.

commit f6800fd04c
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date:   Sun Feb 10 21:43:03 2013 +0100

    Implemented QuerySet.datetimes on PostgreSQL.

commit 0c829c23f4
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date:   Sun Feb 10 21:41:08 2013 +0100

    Added datetime-handling infrastructure in the ORM layers.

commit 104d82a777
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date:   Mon Feb 11 10:05:55 2013 +0100

    Updated null_queries tests to avoid clashing with the __second lookup.

commit c01bbb3235
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date:   Sun Feb 10 23:07:41 2013 +0100

    Updated tests of .dates().

    Replaced .dates() by .datetimes() for DateTimeFields.
    Replaced dates with datetimes in the expected output for DateFields.

commit 50fb7a5246
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date:   Sun Feb 10 21:40:09 2013 +0100

    Updated and added tests for QuerySet.datetimes.

commit a8451a5004
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date:   Sun Feb 10 22:34:46 2013 +0100

    Documented the new time lookups and updated the date lookups.

commit 29413eab2b
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date:   Sun Feb 10 16:15:49 2013 +0100

    Documented QuerySet.datetimes and updated QuerySet.dates.
2013-02-16 09:19:04 +01:00
Anssi Kääriäinen 0478780b8e Fixed #19638 -- Skipped tx support testing for some DBs
PostgreSQL and Oracle always support transactions, so the create table
and rollback test is non-necessary on those DBs.

Thanks to shai for report.
2013-02-10 18:56:36 +02:00
Anssi Kääriäinen a4e97cf315 Fixed #19707 -- Reset transaction state after requests 2013-02-10 13:55:54 +02:00
Claude Paroz e486475a13 Moved import in db.backends.creation 2013-02-08 10:01:56 +01: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
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
Jani Tiainen d194f29057 Fixed #19606 -- Adjusted cx_Oracle unicode detection. 2013-01-19 09:27:16 +02: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
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
Claude Paroz c698c55966 Created special PostgreSQL text indexes when unique is True
Refs #19441.
2013-01-07 17:54:30 +01: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
Andrew Godwin b62e82365a Merge remote-tracking branch 'core/master' into schema-alteration
Conflicts:
	django/db/models/loading.py
	django/db/models/options.py
2012-12-18 09:02:07 +00: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 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
Aymeric Augustin a001f3c31e Fixed #2304 -- Documented TRANSACTIONS_MANAGED. 2012-12-14 21:15:48 +01: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
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
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 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
Alex Gaynor 4285571c5a Fixed #5805 -- it is now possible to specify multi-column indexes. Thanks to jgelens for the original patch. 2012-11-04 10:16:06 -08:00
Aymeric Augustin fc10418fba Fixed #18963 -- Used a subclass-friendly pattern
for Python 2 object model compatibility methods.
2012-11-03 22:07:35 +01:00
Anssi Kääriäinen 2249bd275c Fixed Oracle failure for "%" in table name 2012-10-27 05:26:42 +03:00
Andrew Godwin 6a632e0457 Merge branch 'master' into schema-alteration
Conflicts:
	django/db/backends/__init__.py
	django/db/models/fields/related.py
	django/db/models/options.py
2012-10-26 08:41:13 +01:00
Aymeric Augustin c736a1a9f8 Fixed #19176 -- Typo in copy-pasted error message.
Thanks maxirobaina for the report.
2012-10-24 16:21:30 +02:00
Jan Bednařík 4cceb5cb31 Fixed #19162 -- Wrong indentation. 2012-10-22 19:23:19 +02:00
Anssi Kääriäinen a8b1861fc4 Revert "Fixed #16211 -- Added comparison and negation ops to F() expressions"
This reverts commit 28abf5f0eb.

Conflicts:

	docs/releases/1.5.txt
2012-10-10 01:15:29 +03:00
Anssi Kääriäinen 28abf5f0eb Fixed #16211 -- Added comparison and negation ops to F() expressions
Work done by Walter Doekes and Trac alias knoeb. Reviewed by Simon
Charette.
2012-09-30 17:51:06 +03:00
Russell Keith-Magee 70a0de37d1 Fixed #3011 -- Added swappable auth.User models.
Thanks to the many people that contributed to the development and review of
this patch, including (but not limited to) Jacob Kaplan-Moss, Anssi
Kääriäinen, Ramiro Morales, Preston Holmes, Josh Ourisman, Thomas Sutton,
and Roger Barnes, as well as the many, many people who have contributed to
the design discussion around this ticket over many years.

Squashed commit of the following:

commit d84749a0f0
Merge: 531e771 7c11b1a
Author: Russell Keith-Magee <russell@keith-magee.com>
Date:   Wed Sep 26 18:37:04 2012 +0800

    Merge remote-tracking branch 'django/master' into t3011

commit 531e7715da
Merge: 29d1abb 1f84b04
Author: Russell Keith-Magee <russell@keith-magee.com>
Date:   Wed Sep 26 07:09:23 2012 +0800

    Merged recent trunk changes.

commit 29d1abbe35
Merge: 8a527dd 54c81a1
Author: Russell Keith-Magee <russell@keith-magee.com>
Date:   Mon Sep 24 07:49:46 2012 +0800

    Merge remote-tracking branch 'django/master' into t3011

commit 8a527dda13
Author: Russell Keith-Magee <russell@keith-magee.com>
Date:   Mon Sep 24 07:48:05 2012 +0800

    Ensure sequences are reset correctly in the presence of swapped models.

commit e2b6e22f29
Author: Russell Keith-Magee <russell@keith-magee.com>
Date:   Sun Sep 23 17:53:05 2012 +0800

    Modifications to the handling and docs for auth forms.

commit 98aba856b5
Author: Russell Keith-Magee <russell@keith-magee.com>
Date:   Sun Sep 23 15:28:57 2012 +0800

    Improved error handling and docs for get_user_model()

commit 0229209c84
Merge: 6494bf9 8599f64
Author: Russell Keith-Magee <russell@keith-magee.com>
Date:   Sun Sep 23 14:50:11 2012 +0800

    Merged recent Django trunk changes.

commit 6494bf91f2
Author: Russell Keith-Magee <russell@keith-magee.com>
Date:   Mon Sep 17 21:38:44 2012 +0800

    Improved validation of swappable model settings.

commit 5a04cde342
Author: Russell Keith-Magee <russell@keith-magee.com>
Date:   Mon Sep 17 07:15:14 2012 +0800

    Removed some unused imports.

commit ffd535e413
Author: Russell Keith-Magee <russell@keith-magee.com>
Date:   Sun Sep 16 20:31:28 2012 +0800

    Corrected attribute access on for get_by_natural_key

commit 913e1ac84c
Author: Russell Keith-Magee <russell@keith-magee.com>
Date:   Sun Sep 16 20:12:34 2012 +0800

    Added test for proxy model safeguards on swappable models.

commit 280bf19e94
Merge: dbb3900 935a863
Author: Russell Keith-Magee <russell@keith-magee.com>
Date:   Sun Sep 16 18:16:49 2012 +0800

    Merge remote-tracking branch 'django/master' into t3011

commit dbb3900775
Author: Russell Keith-Magee <russell@keith-magee.com>
Date:   Sun Sep 16 18:09:27 2012 +0800

    Fixes for Python 3 compatibility.

commit dfd72131d8
Author: Russell Keith-Magee <russell@keith-magee.com>
Date:   Sun Sep 16 15:54:30 2012 +0800

    Added protection against proxying swapped models.

commit abcb027190
Author: Russell Keith-Magee <russell@keith-magee.com>
Date:   Sun Sep 16 15:11:10 2012 +0800

    Cleanup and documentation of AbstractUser base class.

commit a9491a8776
Merge: fd8bb4e 08bcb4a
Author: Russell Keith-Magee <russell@keith-magee.com>
Date:   Sun Sep 16 14:46:49 2012 +0800

    Merge commit '08bcb4aec1ed154cefc631b8510ee13e9af0c19d' into t3011

commit fd8bb4e3e4
Author: Russell Keith-Magee <russell@keith-magee.com>
Date:   Sun Sep 16 14:20:14 2012 +0800

    Documentation improvements coming from community review.

commit b550a6d06d
Author: Russell Keith-Magee <russell@keith-magee.com>
Date:   Sun Sep 16 13:52:47 2012 +0800

    Refactored skipIfCustomUser into the contrib.auth tests.

commit 52a02f1110
Author: Russell Keith-Magee <russell@keith-magee.com>
Date:   Sun Sep 16 13:46:10 2012 +0800

    Refactored common 'get' pattern into manager method.

commit b441a6bbc7
Author: Russell Keith-Magee <russell@keith-magee.com>
Date:   Sun Sep 16 13:41:33 2012 +0800

    Added note about backwards incompatible change to admin login messages.

commit 08bcb4aec1
Author: Anssi Kääriäinen <akaariai@gmail.com>
Date:   Sat Sep 15 18:30:33 2012 +0300

    Splitted User to AbstractUser and User

commit d9f5e5addb
Author: Anssi Kääriäinen <akaariai@gmail.com>
Date:   Sat Sep 15 18:30:02 2012 +0300

    Reworked REQUIRED_FIELDS + create_user() interaction

commit 579f152e4a
Merge: 9184972 93e6733
Author: Russell Keith-Magee <russell@keith-magee.com>
Date:   Sat Sep 15 20:18:37 2012 +0800

    Merge remote-tracking branch 'django/master' into t3011

commit 918497218c
Author: Russell Keith-Magee <russell@keith-magee.com>
Date:   Sat Sep 15 20:18:19 2012 +0800

    Deprecate AUTH_PROFILE_MODULE and get_profile().

commit 334cdfc1bb
Author: Russell Keith-Magee <russell@keith-magee.com>
Date:   Sat Sep 15 20:00:12 2012 +0800

    Added release notes for new swappable User feature.

commit 5d7bb22e8d
Author: Russell Keith-Magee <russell@keith-magee.com>
Date:   Sat Sep 15 19:59:49 2012 +0800

    Ensure swapped models can't be queried.

commit 57ac6e3d32
Merge: f2ec915 abfba3b
Author: Russell Keith-Magee <russell@keith-magee.com>
Date:   Sat Sep 15 14:31:54 2012 +0800

    Merge remote-tracking branch 'django/master' into t3011

commit f2ec915b20
Merge: 1952656 5e99a3d
Author: Russell Keith-Magee <russell@keith-magee.com>
Date:   Sun Sep 9 08:29:51 2012 +0800

    Merge remote-tracking branch 'django/master' into t3011

commit 19526563b5
Merge: 2c5e833 c4aa26a
Author: Russell Keith-Magee <russell@keith-magee.com>
Date:   Sun Sep 9 08:22:26 2012 +0800

    Merge recent changes from master.

commit 2c5e833a30
Author: Russell Keith-Magee <russell@keith-magee.com>
Date:   Sun Sep 9 07:53:46 2012 +0800

    Corrected admin_views tests following removal of the email fallback on admin logins.

commit 20d1892491
Author: Russell Keith-Magee <russell@keith-magee.com>
Date:   Sun Sep 9 01:00:37 2012 +0800

    Added conditional skips for all tests dependent on the default User model

commit 40ea8b8882
Author: Russell Keith-Magee <russell@keith-magee.com>
Date:   Sat Sep 8 23:47:02 2012 +0800

    Added documentation for REQUIRED_FIELDS in custom auth.

commit e6aaf65970
Author: Russell Keith-Magee <russell@keith-magee.com>
Date:   Sat Sep 8 23:20:02 2012 +0800

    Added first draft of custom User docs.

    Thanks to Greg Turner for the initial text.

commit 75118bd242
Author: Thomas Sutton <me@thomas-sutton.id.au>
Date:   Mon Aug 20 11:17:26 2012 +0800

    Admin app should not allow username discovery

    The admin app login form should not allow users to discover the username
    associated with an email address.

commit d088b3af58
Author: Thomas Sutton <me@thomas-sutton.id.au>
Date:   Mon Aug 20 10:32:13 2012 +0800

    Admin app login form should use swapped user model

commit 7e82e83d67
Merge: e29c010 39aa890
Author: Russell Keith-Magee <russell@keith-magee.com>
Date:   Fri Sep 7 23:45:03 2012 +0800

    Merged master changes.

commit e29c010beb
Merge: 8e3fd70 30bdf22
Author: Russell Keith-Magee <russell@keith-magee.com>
Date:   Mon Aug 20 13:12:57 2012 +0800

    Merge remote-tracking branch 'django/master' into t3011

commit 8e3fd703d0
Merge: 507bb50 26e0ba0
Author: Russell Keith-Magee <russell@keith-magee.com>
Date:   Mon Aug 20 13:09:09 2012 +0800

    Merged recent changes from trunk.

commit 507bb50a92
Author: Russell Keith-Magee <russell@keith-magee.com>
Date:   Mon Jun 4 20:41:37 2012 +0800

    Modified auth app so that login with alternate auth app is possible.

commit dabe362836
Author: Russell Keith-Magee <russell@keith-magee.com>
Date:   Mon Jun 4 20:10:51 2012 +0800

    Modified auth management commands to handle custom user definitions.

commit 7cc0baf89d
Author: Russell Keith-Magee <russell@keith-magee.com>
Date:   Mon Jun 4 14:17:28 2012 +0800

    Added model Meta option for swappable models, and made auth.User a swappable model
2012-09-26 18:48:09 +08:00
Andrew Godwin b6784bee66 Use create_index_name for FK names 2012-09-24 13:40:56 +01:00
Andrew Godwin 0bcfc068b0 Add second shortener to create_index_name for very long columns 2012-09-24 13:23:25 +01:00
Andrew Godwin d146b250ae Remove one of the last traces of South 2012-09-24 13:18:14 +01:00
Andrew Godwin 3a338d00ec Add comment to usage of m2m_reverse_field_name 2012-09-24 13:17:38 +01:00
Andrew Godwin 49dc1e7d28 Fix altering of indexes alongside uniques 2012-09-24 13:15:08 +01:00
Andrew Godwin 0354cecbfd Fix nullability changing code 2012-09-24 12:56:17 +01:00
Andrew Godwin 588b839b26 Fix NOT NULL sql for MySQL 2012-09-24 12:52:43 +01:00
Andrew Godwin e3c9742cd4 Fix error message for unique constraints 2012-09-24 12:51:50 +01:00
Andrew Godwin 1a6d07783d Do cheaper check for column having a type. 2012-09-24 12:19:32 +01:00
Andrew Godwin f0e09e27f6 Fix non-executed SQL 2012-09-24 12:16:16 +01:00
Andrew Godwin 3074243a5f Fix introspection PK comment more. 2012-09-22 01:22:58 +01:00
Andrew Godwin 45e5eedea9 Remove special-casing for proxy/unmanaged models 2012-09-22 01:17:08 +01:00
Andrew Godwin 49d1e6b0e2 Remove AppCache state handling, replace with swappable caches 2012-09-22 00:47:04 +01:00
Claude Paroz 26ff2be787 Imported getLogger directly from logging module
This was a remainder of some 2.4 compatibility code.
2012-09-20 21:03:24 +02:00
Andrew Godwin ae6ffd2e7e Stylistic fixes: triple-quoted docstrings, more comments 2012-09-18 10:37:30 +01:00
Andrew Godwin c5e2ecae69 Fix bug in get_indexes affecting the tests 2012-09-17 23:45:00 +01:00
Andrew Godwin 9313dea700 Merge remote-tracking branch 'core/master' into schema-alteration
Conflicts:
	django/db/backends/mysql/base.py
	django/db/backends/postgresql_psycopg2/base.py
2012-09-17 20:00:14 +01:00
Claude Paroz 859aa2a6c4 Fixed #18790 -- Encoded database password on Python 2
Thanks thcourbon@gmail.com for the report.
2012-09-12 10:16:49 +02:00
Claude Paroz 09a99714c0 Moved get_primary_key_column implementation to base
Refs #17574.
2012-09-08 10:24:13 +02:00
Andrew Godwin 3ffbfe4abc Stubbed-out oracle schema file 2012-09-07 15:56:07 -04:00
Andrew Godwin 8413c85f3d Very initial Oracle support 2012-09-07 15:48:22 -04:00
Andrew Godwin 828d691f62 Merge branch 'master' into schema-alteration 2012-09-07 15:43:28 -04:00
Andrew Godwin ca9c3cd39f Add check constraint support - needed a few Field changes 2012-09-07 15:40:59 -04:00
Alex Gaynor ad50243cd1 [py3k] Fixed the index creation code that I committed a few minutes ago for py3k. 2012-09-07 15:33:02 -04:00
Alex Gaynor 335a9f9cf1 Removed many uses of bare "except:", which were either going to a) silence real issues, or b) were impossible to hit. 2012-09-07 15:08:07 -04:00
Andrew Godwin 375178fc19 Add M2M repointing 2012-09-07 14:39:22 -04:00
Alex Gaynor e4ea536774 Ensued that SQL indexes are alwasy created in the same name.
Previous this used Python's builtin hash() function, which has never been guarnteed to be stable across implementations (CPython/Jython/etc.) or 32/64 bitness. However, this in practice it was stable. However, with the impending release of Python 3.3 hash randomizations is enabled by default, which would mean the index name changed between program invocations.
2012-09-07 14:14:06 -04:00
Andrew Godwin a92bae0f06 Repoint ForeignKeys when their to= changes. 2012-09-07 13:31:05 -04:00
Andrew Godwin d683263f97 Added SQLite backend which passes all current tests 2012-09-07 12:51:11 -04:00
Andrew Godwin b546e7eb63 Merge branch 'master' into schema-alteration 2012-09-05 09:39:03 -04:00
Andrew Godwin cd583d6dbd Implement primary key changing 2012-09-04 12:53:31 -04:00
Andrew Godwin d865503389 db_index alteration mostly working 2012-08-30 23:11:56 +01:00
Claude Paroz a9a773ff38 Made get_table_description also return the size of char fields on SQLite 2012-08-30 19:36:05 +02:00
Claude Paroz 879b245baa Fixed #5725 -- Fixed varchar column size introspection for MySQL
Thanks ferdonline for the initial patch and Karen Tracey for the
related post on django-users.
2012-08-30 19:28:13 +02:00
Claude Paroz ae88e73fa6 Replaced some smart_xxx by force_xxx equivalent
smart_str/smart_text should only be used when a potential lazy
string should be preserved in the result of the function call.
2012-08-30 15:46:16 +02:00
Claude Paroz ebc773ada3 Replaced many smart_bytes by force_bytes
In all those occurrences, we didn't care about preserving the
lazy status of the strings, but we really wanted to obtain a
real bytestring.
2012-08-29 11:20:32 +02:00
Aymeric Augustin 5301a9d7b1 [py3] Removed duplicate imports.
Fixed #18837. Refs #18791.
2012-08-23 10:16:16 +02:00
Claude Paroz bfc380baea [py3] Prepared MySQL backend for Python 3 compatibility 2012-08-20 10:46:21 +02:00
Anssi Kääriäinen 4db38cbfe1 [py3] Fixed Oracle specific failures 2012-08-19 23:45:26 +03:00
Aymeric Augustin 547b181046 [py3] Ported django.utils.safestring.
Backwards compatibility aliases were created under Python 2.
2012-08-18 16:04:06 +02:00
Andrew Godwin d3d1e59921 Add a SQlite backend. One test passes! 2012-08-18 14:16:52 +01:00
Andrew Godwin f7955c703d All tests passing on MySQL 2012-08-18 13:48:54 +01:00
Andrew Godwin cab044c66c First stab at MySQL support 2012-08-18 12:29:31 +01:00
Aymeric Augustin f34de7dd6e [py3] Fixed backends tests. 2012-08-18 11:02:38 +02:00
Aymeric Augustin 4c1286cf78 [py3] Added compatibility import of thread/_thread
This commit fixes the auto-reload of the development server.

I should have done that change in ca07fda2.
2012-08-18 10:56:56 +02:00
Dmitry Shevchenko 4412de5d8d [py3] Fixed installed_models filtering. 2012-08-16 01:08:45 -05:00
Claude Paroz 187ec5a166 [py3] Pass bytes to md5 in truncate_name 2012-08-15 12:37:08 +02:00
Aymeric Augustin 9299dc42ed [py3] Removed unnecessary calls to .keys()
when computing the length of a dictionary. This fails on Python 3.
2012-08-14 14:09:23 +02:00
Anssi Kääriäinen 1930b899bd Refix #13844 -- Made FloatField aggregates work on Python 2.6 + Postgres
Fixed a regression introduced in 59a655988e.
2012-08-13 09:15:20 +03:00
Anssi Kääriäinen 59a655988e Fixed #13844 -- Avoid converting unknown db values to float
This patch removes an unconditional float(value) conversion from db
backend default convert_values() method. This can cause problems when
aggregating over character fields for example. In addition, Oracle
and SQLite already return the bare value from their convert_values().

In the long term the converting should be done by fields, and the
fields should then call database backend specific converters when
needed. The current setup is inflexible for 3rd party fields.

Thanks to Merlijn van Deen for the original patch.
2012-08-12 21:52:52 +03:00
Claude Paroz 5513480fe1 [py3] Always convert values from sqlite3 to unicode strings
Thanks Aymeric Augustin for the review.
2012-08-12 20:47:18 +02:00
Andrew Godwin 60873ea2ad Add db_table and db_tablespace handling 2012-08-10 15:03:18 +01:00
Andrew Godwin 184cf9ab79 Merge branch 'master' into schema-alteration 2012-08-10 12:40:37 +01:00
Andrew Godwin c4b2a3262c Add support for unique_together 2012-08-10 12:38:18 +01:00
Aymeric Augustin 5c09c59bc7 [py3] Renamed `next` to `__next__` in iterators.
See PEP 3114. `next` is retained as an alias for Python 2.
2012-08-09 14:36:05 +02:00
Claude Paroz b8e49d70f2 [py3] Replaced raw_input by input
The six addition has been borrowed from:
https://bitbucket.org/gutworth/six/changeset/733ef740
2012-08-08 19:53:11 +02:00
Aymeric Augustin c5ef65bcf3 [py3] Ported django.utils.encoding.
* Renamed smart_unicode to smart_text (but kept the old name under
  Python 2 for backwards compatibility).
* Renamed smart_str to smart_bytes.
* Re-introduced smart_str as an alias for smart_text under Python 3
  and smart_bytes under Python 2 (which is backwards compatible).
  Thus smart_str always returns a str objects.
* Used the new smart_str in a few places where both Python 2 and 3
  want a str.
2012-08-07 12:00:22 +02:00
Aymeric Augustin ee191715ea [py3] Fixed access to dict keys/values/items. 2012-08-07 12:00:22 +02:00
Claude Paroz 9908201d7f Replaced some byte strings by str() calls
This is a useful trick when Python 2 awaits byte strings and
Python 3 Unicode (regular) strings.
2012-08-03 15:18:13 +02:00
Andrew Godwin b139315f1c Add M2M tests and some unique support 2012-08-02 15:08:39 +01:00
Andrew Godwin 4a2e80fff4 Merge branch 'master' of github.com:django/django into schema-alteration
Conflicts:
	django/db/backends/postgresql_psycopg2/base.py
2012-07-26 18:58:10 +01:00
Ramiro Morales f758bdab5e Fixed #18271 -- Changed stage at which TransactionTestCase flushes DB tables.
Previously, the flush was done before the test case execution and now
it is performed after it.

Other changes to the testing infrastructure include:

* TransactionTestCase now doesn't reset autoincrement sequences either
  (previous behavior can achieved by using `reset_sequences`.)
  With this, no implicit such reset is performed by any of the provided
  TestCase classes.

* New ordering of test cases: All unittest tes cases are run first and
  doctests are run at the end.

THse changes could be backward-incompatible with test cases that relied
on some kind of state being preserved between tests. Please read the
relevant sections of the release notes and testing documentation for
further details.

Thanks Andreas Pelme for the initial patch. Karen Tracey and Anssi
Kääriäinen for the feedback and Anssi for reviewing.

This also fixes #12408.
2012-07-24 17:24:16 -03:00
Aymeric Augustin ca07fda2ef [py3] Switched to Python 3-compatible imports.
xrange/range will be dealt with in a separate commit due to the huge
number of changes.
2012-07-22 09:29:56 +02:00
Aymeric Augustin bdca5ea345 [py3] Replaced unicode/str by six.text_type/bytes. 2012-07-22 09:29:54 +02:00
Aymeric Augustin 3cb2457f46 [py3] Replaced basestring by six.string_types. 2012-07-22 09:29:54 +02:00
Aymeric Augustin 56dbe924a6 [py3] Removed longs. 2012-07-22 09:29:53 +02:00
Aymeric Augustin 7fa51a24a8 [py3] Exception aren't iterable in Python 3. 2012-07-22 09:29:52 +02:00
Aymeric Augustin d796c94b03 [py3] Used six.reraise wherever necessary. 2012-07-22 09:29:52 +02:00
Anssi Kääriäinen 29132ebdef Fixed #17788 -- Added batch_size argument to qs.bulk_create()
The qs.bulk_create() method did not work with large batches together
with SQLite3. This commit adds a way to split the bulk into smaller
batches. The default batch size is unlimited except for SQLite3 where
the batch size is limited to 999 SQL parameters per batch.

Thanks to everybody who participated in the discussions at Trac.
2012-07-17 15:24:41 +03:00
Claude Paroz 828f7b62e8 Fixed #18602 -- Improved error message when database NAME is missing
Thanks Kristian Glass for the report.
2012-07-10 13:22:55 +02:00
Anssi Kääriäinen d3c2eb103f Fixed #18330 - Made cache culling 3rd party db backend friendly
This is Ian Kelly's patch from #15580 with minor modifications.
2012-07-05 17:20:48 +03:00
Anssi Kääriäinen f572ee0c65 Fixed #16047 -- Restore autocommit state correctly on psycopg2
When the postgresql_psycopg2 backend was used with DB-level autocommit
mode enabled, after entering transaction management and then leaving
it, the isolation level was never set back to autocommit mode.

Thanks brodie for report and working on this issue.
2012-07-01 19:36:43 +03:00
Anssi Kääriäinen da573fbb41 Fixed some locations to work with autocommit=True
- backends: supports_transactions()
 - select_for_update tests
2012-07-01 19:27:36 +03:00
Josh Smeaton fa182e8ae8 Fixed #18465 -- Set date formats correctly on Oracle
Correctly configure NLS_SESSION_PARAMETERS to format Date and DateTime
on Oracle backend.

Thanks to Josh Smeaton for report & patch.
2012-06-26 19:39:14 +03:00
Andrew Godwin 959a3f9791 Add some field schema alteration methods and tests. 2012-06-19 13:25:22 +01:00
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 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
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
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 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 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
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
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
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 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 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
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
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
Aymeric Augustin 8d71734f15 Fixed #17923 -- Added missing import in the MySQL and Oracle backends. Thanks aldaran for the report. Also removed two duplicate imports.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17758 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2012-03-17 09:11:24 +00:00
Aymeric Augustin 3ef55dfaa0 Fixed #17882 (again) -- Updated the database connections' time zone when time-zone-related settings are changed in tests.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17709 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2012-03-13 23:29:15 +00:00
Ramiro Morales 69b96f824d Fixed #16329 -- Fixed detection of transaction-handling capabilities when all test databases are sqlite3, in-memory.
Thanks canassa for the report and agriffis (#17762) and lrekucki (in #17758) for their contribution to the fix.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17702 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2012-03-13 17:52:48 +00:00