Shipeng Feng
8fe2447a01
Fixed #31392 -- Avoided unnecessary SchemaEditor.effective_default() calls when altering a field.
2020-03-24 13:09:43 +01:00
Simon Charette
9f07f27124
Fixed #31376 -- Optimized nulls ordering when possible on SQLite and MySQL.
...
Both backends order NULLs first on ascending ordering and last on
descending ordering which makes ORDER BY IS (NOT)? NULL wasteful when
asc(nulls_first) and desc(nulls_last) are used since it prevents indice
usage.
2020-03-18 06:43:49 +01:00
shankarj67
df4d622cac
Fixed #31345 -- Added BaseDatabaseIntrospection.get_relations().
2020-03-06 08:53:32 +01:00
aryan
427a7e419b
Fixed #31333 -- Added BaseDatabaseIntrospection.get_table_description().
2020-03-04 12:26:31 +01:00
Matthijs Kooijman
98f23a8af0
Fixed #26552 -- Deferred constraint checks when reloading the database with data for tests.
...
deserialize_db_from_string() loads the full serialized database
contents, which might contain forward references and cycles. That
caused IntegrityError because constraints were checked immediately.
Now, it loads data in a transaction with constraint checks deferred
until the end of the transaction.
2020-02-14 13:18:06 +01:00
Jon Dufresne
f48f671223
Refs #31233 -- Changed DatabaseWrapper._nodb_connection to _nodb_cursor().
...
It is now a method instead of a property and returns a context manager
that yields a cursor on entry and closes the cursor and connection upon
exit.
2020-02-06 15:29:38 +01:00
Nick Pope
335c9c94ac
Simplified imports from django.db and django.contrib.gis.db.
2020-02-04 13:20:06 +01:00
Tim Graham
227d0c7365
Fixed #31183 -- Added a feature flag for "<db> only supports UNBOUNDED together with PRECEDING and FOLLOWING".
2020-01-20 20:03:35 +01:00
Simon Charette
9bcbcd599a
Fixed #31133 -- Fixed crash when subtracting against a subquery annotation.
...
The subtract_temporals() database operation was not handling expressions
returning SQL params in mixed database types.
Regression in 3543129822
.
Thanks Reupen Shah for the report.
2020-01-03 10:35:08 +01:00
Aymeric Augustin
c06492dd87
Fixed #23524 -- Allowed DATABASES['TIME_ZONE'] option on PostgreSQL.
2019-12-04 18:22:08 +01:00
Aymeric Augustin
ad88524e4d
Refs #23524 -- Unified BaseDatabaseWrapper.timezone.
...
There was a special case in this property to return None when the
database backend supports time zone. However, only the PostgreSQL
backend supports time zones and it never uses this property.
2019-12-04 18:07:51 +01:00
Jon Dufresne
f5ebdfce5c
Fixed #25388 -- Added an option to allow disabling of migrations during test database creation.
2019-11-20 20:42:38 +01:00
Caio Ariede
555bebe774
Fixed #30987 -- Added models.PositiveBigIntegerField.
2019-11-19 09:34:11 +01:00
Jon Dufresne
57a3d96ff5
Replaced unnecessary str()/bytes() calls with literals.
2019-11-18 15:30:10 +01:00
Nick Pope
7286eaf681
Refs #13312 -- Simplified handling of nulls ordering on MySQL.
...
MySQL & MariaDB support the standard IS NULL and IS NOT NULL so
the same workaround used for NULLS FIRST and NULLS LAST that is
used for SQLite < 3.30.0 can be used.
Thanks Simon Charette for the discussion.
2019-11-04 14:47:58 +01:00
Mariusz Felisiak
01104368ff
Refs #29444 -- Removed redundant DatabaseFeatures.can_return_multiple_columns_from_insert.
...
Unnecessary since b31e63879e
.
2019-09-24 10:37:22 +02:00
Johannes Hoppe
b31e63879e
Fixed #29444 -- Allowed returning multiple fields from INSERT statements on Oracle.
2019-09-24 10:22:43 +02:00
Adnan Umer
241deed259
Fixed #30591 -- Fixed recreation of foreign key constraints on MySQL when altering type of referenced unique field.
...
Thanks Mariusz Felisiak for tests and Matthijs Kooijman for
investigation and initial patch.
2019-09-11 11:21:08 +02:00
Vojtech Bocek
b1d37fea8f
Fixed #28107 -- Added DatabaseFeatures.allows_group_by_selected_pks_on_model() to allow enabling optimization for unmanaged models.
2019-09-09 14:04:46 +02:00
Johannes Hoppe
7254f1138d
Refs #29444 -- Allowed returning multiple fields from INSERT statements on PostgreSQL.
...
Thanks Florian Apolloner, Tim Graham, Simon Charette, Nick Pope, and
Mariusz Felisiak for reviews.
2019-09-09 10:51:14 +02:00
Matthew Schinckel
4137fc2efc
Fixed #25367 -- Allowed boolean expressions in QuerySet.filter() and exclude().
...
This allows using expressions that have an output_field that is a
BooleanField to be used directly in a queryset filters, or in the
When() clauses of a Case() expression.
Thanks Josh Smeaton, Tim Graham, Simon Charette, Mariusz Felisiak, and
Adam Johnson for reviews.
Co-Authored-By: NyanKiyoshi <hello@vanille.bid>
2019-08-29 09:45:29 +02:00
Nasir Hussain
6b16c91157
Fixed #30712 -- Allowed BLOB/TEXT defaults on MySQL 8.0.13+.
2019-08-22 12:23:10 +02:00
Mads Jensen
85ac838d9e
Fixed #21039 -- Added AddIndexConcurrently/RemoveIndexConcurrently operations for PostgreSQL.
...
Thanks to Simon Charettes for review.
Co-Authored-By: Daniel Tao <daniel.tao@gmail.com>
2019-08-21 13:10:06 +02:00
Nick Pope
21e559495b
Fixed #29979 , Refs #17337 -- Extracted AutoField field logic into a mixin and refactored AutoFields.
...
This reduces duplication by allowing AutoField, BigAutoField and
SmallAutoField to inherit from IntegerField, BigIntegerField and
SmallIntegerField respectively. Doing so also allows for enabling the
max_length warning check and minimum/maximum value validation for auto
fields, as well as providing a mixin that can be used for other possible
future auto field types such as a theoretical UUIDAutoField.
2019-08-20 09:22:25 +02:00
Simon Charette
efa1908f66
Refs #25367 -- Moved Oracle Exists() handling to contextual methods.
...
Oracle requires the EXISTS expression to be wrapped in a CASE WHEN in
the following cases.
1. When part of a SELECT clause.
2. When part of a ORDER BY clause.
3. When compared against another expression in the WHERE clause.
This commit moves the systematic CASE WHEN wrapping of Exists.as_oracle
to contextual .select_format, Lookup.as_oracle, and OrderBy.as_oracle
methods in order to avoid unnecessary wrapping.
2019-08-13 06:48:14 +02:00
Simon Charette
2fb872e56f
Refs #23879 -- Made introspection respect required_db_features.
2019-08-12 06:33:46 +02:00
Nick Pope
194d1dfc18
Fixed #30661 -- Added models.SmallAutoField.
2019-08-02 11:39:01 +02:00
Mariusz Felisiak
d14fa04ab3
Removed obsolete mentions of a check constraint in BaseDatabaseSchemaEditor.add_constraint()/remove_constraint() docstrings.
2019-08-02 07:09:37 +02:00
Hasan Ramezani
1fc2c70f76
Fixed #30593 -- Added support for check constraints on MariaDB 10.2+.
2019-07-19 11:05:06 +02:00
Johannes Hoppe
bc91f27a86
Refs #29444 -- Added support for fetching a returned non-integer insert values on Oracle.
...
This is currently not actively used, since the ORM will ask the
SQL compiler to only return auto fields.
2019-07-08 08:53:08 +02:00
Min ho Kim
fbb83fefd4
Fixed typos in comments and docs.
2019-07-02 09:36:17 +02:00
Andrew Godwin
a415ce70be
Fixed #30451 -- Added ASGI handler and coroutine-safety.
...
This adds an ASGI handler, asgi.py file for the default project layout,
a few async utilities and adds async-safety to many parts of Django.
2019-06-20 12:29:43 +02:00
Przemysław Suliga
af5ec222cc
Used time.monotonic() instead of time.time() where applicable.
...
time.monotonic() available from Python 3.3:
- Nicely communicates a narrow intent of "get a local system monotonic
clock time" instead of possible "get a not necessarily accurate Unix
time stamp because it needs to be communicated to outside of this
process/machine" when time.time() is used.
- Its result isn't affected by the system clock updates.
There are two classes of time.time() uses changed to time.monotonic()
by this change:
- measuring time taken to run some code.
- setting and checking a "close_at" threshold for for persistent db
connections (django/db/backends/base/base.py).
2019-05-08 18:34:22 +02:00
Rob Golding-Day
4043dc69cd
Fixed #30444 -- Moved SQL generation for tables to BaseDatabaseSchemaEditor.table_sql().
2019-05-07 10:28:14 +02:00
Ville Skyttä
03db5fddfd
Fixed typos in docs, comments, and exception messages.
2019-04-18 09:33:53 +02:00
Paveł Tyślacki
5c17c273ae
Refs #30172 -- Prevented removing a model Meta's index/unique_together from removing Meta constraints/indexes.
2019-03-17 20:50:57 -04:00
Paveł Tyślacki
4bb859e246
Refs #30172 -- Prevented removing a field's check or unique constraint from removing Meta constraints.
2019-03-17 20:50:22 -04:00
Hang Park
142e1ead76
Fixed #30242 -- Removed extra space before LIMIT/OFFSET SQL.
2019-03-09 21:32:20 +01:00
Jon Dufresne
76990cbbda
Fixed #30171 -- Fixed DatabaseError in servers tests.
...
Made DatabaseWrapper thread sharing logic reentrant. Used a reference
counting like scheme to allow nested uses.
The error appeared after 8c775391b7
.
2019-02-14 10:04:55 -05:00
Dan Davis
2bd8df243a
Fixed #30184 -- Removed ellipsis characters from shell output strings.
...
Partially reverted 50b8493581
(refs #29654 )
to avoid a crash when the user shell doesn't support non-ASCII characters.
2019-02-13 13:59:44 -05:00
Simon Charette
b8c48d06fa
Refs #26608 -- Added a database feature for fixed frame range distance support.
2019-02-09 08:47:41 -05:00
Aymeric Augustin
3bb6a4390c
Refs #27753 -- Favored force/smart_str() over force/smart_text().
2019-02-06 14:12:06 -05:00
Johannes Hoppe
b131f9c79f
Refs #29444 -- Renamed DatabaseFeatures.can_return_id* to be generic for other columns.
2019-01-30 15:31:56 -05:00
Tim Graham
7e6b214ed3
Fixed #30116 -- Dropped support for Python 3.5.
2019-01-30 10:19:48 -05:00
Dan Tao
738faf9da2
Fixed #30108 -- Allowed adding foreign key constraints in the same statement that adds a field.
2019-01-29 15:42:57 -05:00
Paveł Tyślacki
b69f8eb04c
Fixed #30062 -- Added support for unique conditional constraints.
2019-01-12 09:50:20 -05:00
Paveł Tyślacki
1e837c4b23
Used None as the empty value for condition in Index's SQL construction.
2019-01-12 09:34:10 -05:00
Paveł Tyślacki
647be06538
Renamed variables after generalization of constraints.
...
Follow up to 8eae094638
.
2019-01-10 18:54:41 -05:00
Nick Pope
a35d2a4510
Refs #23748 -- Added AutoField introspection for SQLite.
2019-01-09 09:59:15 -05:00
Mariusz Felisiak
97844a3213
Fixed typo in django/db/backends/base/features.py.
2019-01-03 20:10:33 +01:00
Paveł Tyślacki
0123b67f6b
Fixed #30060 -- Moved SQL generation for indexes and constraints to SchemaEditor.
2019-01-01 09:39:58 -05:00
Tim Graham
b74b6736d0
Refs #29547 -- Skipped an unsupported partial index test on older versions of SQLite.
...
Follow up to e5b8626c0e
.
2018-12-26 11:20:11 -05:00
Nick Pope
83677faf86
Fixed #30056 -- Added SQLite support for StdDev and Variance functions.
2018-12-24 11:14:58 -05:00
Simon Charette
20f6f9eaa1
Renamed SQLite3 references to to SQLite.
...
The version suffix isn't part of the product name.
2018-12-22 14:20:43 -05:00
Mariusz Felisiak
f9a33e3c3f
Fixed #29932 -- Fixed combining compound queries with sub-compound queries on SQLite and Oracle.
2018-12-06 15:31:33 -05:00
Mariusz Felisiak
f091ea3515
Refs #29722 -- Added introspection of materialized views for Oracle.
...
Thanks Tim Graham for the review.
2018-11-26 19:45:05 +01:00
Mariusz Felisiak
d5f4ce9849
Fixed #29949 -- Refactored db introspection identifier converters.
...
Removed DatabaseIntrospection.table_name_converter()/column_name_converter()
and use instead DatabaseIntrospection.identifier_converter().
Removed DatabaseFeatures.uppercases_column_names.
Thanks Tim Graham for the initial patch and review and Simon Charette
for the review.
2018-11-21 09:06:50 +01:00
Tim Graham
acdd18dffc
Changed BaseDatabaseSchemaEditor._effective_default() to staticmethod.
...
Follow up to 9cac10eee4
.
2018-11-20 18:01:18 -05:00
Tim Graham
9cac10eee4
Added BaseDatabaseSchemaEditor._effective_default() to allow testing without a connection.
2018-11-17 19:27:53 -05:00
Tim Graham
e62f6e0968
Fixed #29505 -- Removed SchemaEditor's calling of callable defaults.
...
Thanks Eugene Pakhomov for the suggested fix.
2018-11-17 19:27:53 -05:00
Simon Charette
dba4a634ba
Refs #29641 -- Refactored database schema constraint creation.
...
Added a test for constraint names in the database.
Updated SQLite introspection to use sqlparse to allow reading the
constraint name for table check and unique constraints.
Co-authored-by: Ian Foote <python@ian.feete.org>
2018-11-13 15:25:44 -05:00
Tim Graham
f82be9ebc7
Fixed #29934 -- Added sqlparse as a require dependency.
2018-11-09 19:09:36 -05:00
Mads Jensen
a906c98982
Fixed #29547 -- Added support for partial indexes.
...
Thanks to Ian Foote, Mariusz Felisiak, Simon Charettes, and
Markus Holtermann for comments and feedback.
2018-10-29 19:34:54 -04:00
Tim Graham
717ee63e56
Refs #27025 -- Removed obsolete sqlite3 transaction management workaround for Python 3.6+.
...
Obsolete per https://bugs.python.org/issue10740#msg274816 .
2018-10-25 19:54:48 -04:00
Tim Graham
9b52bd6575
Made DatabaseFeatures.uses_savepoints default to True.
2018-10-25 10:02:47 -04:00
Mariusz Felisiak
328f5627dd
Fixed #29870 -- Added DurationField introspection for Oracle and PostgreSQL.
...
Thanks Tim Graham for the review.
2018-10-21 09:08:05 +02:00
Jon Dufresne
0bf7b25f8f
Added django.db.backends.utils.names_digest() to remove redundant code.
2018-10-02 10:41:43 -04:00
Claude Paroz
fc3a463048
Fixed #29767 -- Made date-related casts work on SQLite
...
Thanks Rémy Hubscher for the report and Tim Graham and Simon Charette for the reviews.
2018-10-01 13:27:30 +02:00
Jon Dufresne
82f286cf6f
Refs #29784 -- Switched to https:// links where available.
2018-09-26 08:48:47 +02:00
Oleg
d1d5c97bc2
Fixed #29778 -- Fixed quoting of unique index names.
...
Regression in 3b429c9673
.
2018-09-25 16:00:20 -04:00
Jon Dufresne
abeed587b1
Refs #27795 -- Removed force_bytes() usage in db/backends/base/schema.py.
2018-09-25 09:54:06 -04:00
Tom Forbes
9cbdb44014
Fixed #23646 -- Added QuerySet.bulk_update() to efficiently update many models.
2018-09-18 16:14:44 -04:00
Jon Dufresne
5311a36da5
Refs #29654 -- Replaced three dots with ellipsis in DB creation output strings.
2018-08-28 07:56:34 -04:00
Claude Paroz
50b8493581
Refs #29654 -- Replaced three dots with ellipsis character in output strings.
2018-08-22 09:13:58 -04:00
Tom
f1fbef6cd1
Fixed #28668 -- Allowed QuerySet.bulk_create() to ignore insert conflicts.
2018-08-03 17:40:46 -04:00
Tom Forbes
4198445afc
Refs #29548 -- Fixed failing window tests on MariaDB 10.3.
2018-07-30 19:54:56 -04:00
Claude Paroz
65503ca097
Fixed #29040 -- Made test database creation messages use a consistent output stream.
2018-07-19 18:05:33 -04:00
Oliver Sauder
a07a49ee32
Fixed #29559 -- Fixed TransactionTestCase.reset_sequences for auto-created m2m through models.
2018-07-11 17:20:29 -04:00
Ian Foote
952f05a6db
Fixed #11964 -- Added support for database check constraints.
2018-07-10 15:32:33 -04:00
Ian Foote
38cada7c94
Fixed #28077 -- Added support for PostgreSQL opclasses in Index.
...
Thanks Vinay Karanam for the initial patch.
2018-06-29 17:00:28 -04:00
Mariusz Felisiak
6dd4edb1b4
Fixed #29496 -- Fixed crash on Oracle when converting a non-unique field to primary key.
...
Thanks Tim Graham for the review.
2018-06-17 08:51:02 +02:00
Tom
c1c163b427
Fixed #28574 -- Added QuerySet.explain().
2018-04-19 10:52:19 -04:00
Jeremy Bowman
ee17bb8a67
Fixed #29193 -- Prevented unnecessary foreign key drops when altering a unique field.
...
Stopped dropping and recreating foreign key constraints on other fields
in the same table as the one which is actually being altered in an
AlterField operation.
Regression in c3e0adcad8
.
2018-04-11 23:17:11 -04:00
Mariusz Felisiak
6141c752fe
Fixed #29251 -- Added bytes to str conversion in LPad/RPad database functions on MySQL.
...
Thanks Tim Graham for the review.
2018-04-03 18:24:04 +02:00
Tim Graham
6421bd702f
Refs #29227 -- Made inspectdb generate BooleanField(null=True) rather than NullBooleanField.
2018-03-20 12:10:10 -04:00
Tim Graham
f8b98f0edc
Removed DatabaseFeatures.can_introspect_null.
...
The only known usage is in the unmaintained django-pymssql project.
2018-03-16 11:43:41 -04:00
Tomer Chachamu
c12745f682
Fixed typo in django/db/backends/base/schema.py.
2018-03-12 13:49:36 -04:00
Дилян Палаузов
45aaf6608d
Removed unused variable in BaseDatabaseSchemaEditor.effective_default().
2018-03-12 12:06:06 -04:00
Mariusz Felisiak
074a2f7f58
Refs #28909 -- Simplifed code using unpacking generalizations.
2018-02-26 18:23:31 +01:00
Matthew Wilkes
2162f0983d
Fixed #24747 -- Allowed transforms in QuerySet.order_by() and distinct(*fields).
2018-02-10 19:08:55 -05:00
Mariusz Felisiak
34b52f8572
Renamed the allow_sliced_subqueries database feature to allow_sliced_subqueries_with_in.
...
After 0899d583bd
this database feature is
false only on MySQL which doesn't support sliced subqueries only with
IN/ALL/ANY/SOME.
2018-02-07 08:27:47 +01:00
Tim Martin
02365d3f38
Fixed #28542 -- Fixed deletion of primary key constraint if the new field is unique.
2018-01-13 20:11:55 -05:00
Дилян Палаузов
a38ae914d8
Fixed #28996 -- Simplified some boolean constructs and removed trivial continue statements.
2018-01-12 12:44:50 -05:00
Sergey Fedoseev
ae1baa7d1d
Refs #28459 -- Improved performance of loading DurationField on SQLite and MySQL.
2017-12-27 12:23:08 -05:00
Nick Pope
f3a98224e6
Refs #28909 -- Simplifed code using unpacking generalizations.
2017-12-21 21:05:23 -05:00
Mariusz Felisiak
fc48047586
Refs #28876 -- Fixed incorrect foreign key constraint name for models with quoted db_table.
...
Thanks Simon Charette and Tim Graham for the review and Carlos E. C.
Leite for the report.
2017-12-05 21:11:20 +01:00
Simon Charette
095c1aaa89
Fixed #28849 -- Fixed referenced table and column rename on SQLite.
...
Thanks Ramiro for the input and Tim for the review.
2017-12-01 22:12:24 -05:00
Tim Graham
c3e0adcad8
Fixed #28305 -- Fixed "Cannot change column 'x': used in a foreign key constraint" crash on MySQL with a sequence of AlterField or RenameField operations.
...
Regression in 45ded053b1
.
2017-12-01 19:07:46 -05:00
Jon Dufresne
7a6fbf36b1
Fixed #28853 -- Updated connection.cursor() uses to use a context manager.
2017-11-28 11:28:09 -05:00
Simon Charette
ee85ef8315
Fixed #28792 -- Fixed index name truncation of namespaced tables.
...
Refs #27458 , #27843 .
Thanks Tim and Mariusz for the review.
2017-11-14 21:36:25 -05:00