Commit Graph

140 Commits

Author SHA1 Message Date
coagulant 3bc0d46a84 Fixed all E261 warnings 2013-11-02 18:20:39 -04:00
Florian Hahn 5240b83462 Fixed #17027 -- Added support for the power operator in F expressions.
Thanks dan at dlo.me for the initial patch.

- Added __pow__ and __rpow__ to ExpressionNode
- Added oracle and mysql specific power expressions
- Added used-defined power function for sqlite
2013-10-22 10:29:57 -04:00
Aymeric Augustin 91547772e0 Fixed #21235 -- Disabled savepoints for old versions of SQLite.
Thanks Ramiro for the report.
2013-10-07 10:47:50 +02:00
Aymeric Augustin 728548e483 Fixed #21134 -- Prevented queries in broken transactions.
Squashed commit of the following:

commit 63ddb271a44df389b2c302e421fc17b7f0529755
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date:   Sun Sep 29 22:51:00 2013 +0200

    Clarified interactions between atomic and exceptions.

commit 2899ec299228217c876ba3aa4024e523a41c8504
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date:   Sun Sep 22 22:45:32 2013 +0200

    Fixed TransactionManagementError in tests.

    Previous commit introduced an additional check to prevent running
    queries in transactions that will be rolled back, which triggered a few
    failures in the tests. In practice using transaction.atomic instead of
    the low-level savepoint APIs was enough to fix the problems.

commit 4a639b059ea80aeb78f7f160a7d4b9f609b9c238
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date:   Tue Sep 24 22:24:17 2013 +0200

    Allowed nesting constraint_checks_disabled inside atomic.

    Since MySQL handles transactions loosely, this isn't a problem.

commit 2a4ab1cb6e83391ff7e25d08479e230ca564bfef
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date:   Sat Sep 21 18:43:12 2013 +0200

    Prevented running queries in transactions that will be rolled back.

    This avoids a counter-intuitive behavior in an edge case on databases
    with non-atomic transaction semantics.

    It prevents using savepoint_rollback() inside an atomic block without
    calling set_rollback(False) first, which is backwards-incompatible in
    tests.

    Refs #21134.

commit 8e3db393853c7ac64a445b66e57f3620a3fde7b0
Author: Aymeric Augustin <aymeric.augustin@m4x.org>
Date:   Sun Sep 22 22:14:17 2013 +0200

    Replaced manual savepoints by atomic blocks.

    This ensures the rollback flag is handled consistently in internal APIs.
2013-09-30 09:42:27 +02:00
Tim Graham 18ffdb1772 Fixed #17627 -- Renamed util.py files to utils.py
Thanks PaulM for the suggestion and Luke Granger-Brown and
Wiktor Kołodziej for the initial patch.
2013-09-16 12:52:05 -04:00
Andrew Godwin efd1e6096e Adding 'sqlmigrate' command and quote_parameter to support it. 2013-09-06 15:28:12 -05:00
Chris Wilson eade315da1 Fixed #10164 -- Made AutoField increase monotonically on SQLite
Thanks malte for the report.
2013-09-06 12:31:17 -04:00
Aymeric Augustin 365c3e8b73 Replaced "not PY3" by "PY2", new in six 1.4.0. 2013-09-02 12:11:02 +02:00
Claude Paroz 169637649b Fixed #20984 -- Stopped decoding bytes in sqlite3 adapter on Python 3
Thanks lvella at gmail.com for the report.
2013-08-29 08:39:06 +02: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
Julien Phalip 47c755327b Fixed a number of minor misspellings. 2013-07-27 18:46:03 -07: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
Alex Gaynor 03d9566e0d A large number of stylistic cleanups across django/db/ 2013-07-08 10:39:54 +10: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
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
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 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 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 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 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 f515619494 Added an API to control database-level autocommit. 2013-03-11 14:48:53 +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
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
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
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
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
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
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 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 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
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
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
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
Aymeric Augustin bdca5ea345 [py3] Replaced unicode/str by six.text_type/bytes. 2012-07-22 09:29:54 +02:00