summaryrefslogtreecommitdiff
path: root/django/db/backends/mysql
AgeCommit message (Collapse)Author
2026-04-18Fixed #37028 -- Added BitAnd(), BitOr(), and BitXor() aggregates.Mariusz Felisiak
2026-03-19Fixed #36795 -- Enforced quoting of all database object names.Simon Charette
This ensures all database identifiers are quoted independently of their orign and most importantly that user provided aliases through annotate() and alias() which paves the way for dropping the allow list of characters such aliases can contain. This will require adjustments to raw SQL interfaces such as RawSQL that might make reference to ORM managed annotations as these will now be quoted. The `SQLCompiler.quote_name_unless_alias` method is kept for now as an alias for the newly introduced `.quote_name` method but will be duly deprecated in a follow up commit.
2026-03-12Fixed #36727 -- Deprecated Field.get_placeholder in favor of ↵Simon Charette
get_placeholder_sql. The lack of ability of the get_placeholder call chain to return SQL and parameters separated so they can be mogrified by the backend at execution time forced implementations to dangerously interpolate potentially user controlled values. The get_placeholder_sql name was chosen due to its proximity to the previous method, but other options such as Field.as_sql were considered but ultimately rejected due to its different input signature compared to Expression.as_sql that might have lead to confusion. There is a lot of overlap between what Field.get_db_prep_value and get_placeholder_sql do but folding the latter in the former would require changing its return signature to return expression which is a way more invasive change than what is proposed here. Given we always call get_db_prep_value it might still be an avenue worth exploring in the future to offer a publicly documented interface to allow field to take an active part in the compilation chain. Thanks Jacob for the review.
2026-01-25Fixed #36812 -- Dropped support for MariaDB < 10.11.Skyiesac
2026-01-18Applied Black's 2026 stable style.Mariusz Felisiak
https://github.com/psf/black/releases/tag/26.1.0
2025-12-12Fixed #36735 -- Added UUID4 and UUID7 database functions.Lily Acorn
Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
2025-10-31Fixed #36661 -- Added introspection of database-level delete options.Mariusz Felisiak
2025-10-27Fixed #36624 -- Dropped support for MySQL < 8.4.Mariusz Felisiak
2025-10-18Fixed #21961 -- Added support for database-level delete options for ForeignKey.Mariusz Felisiak
Thanks Simon Charette for pair programming. Co-authored-by: Nick Stefan <NickStefan12@gmail.com> Co-authored-by: Akash Kumar Sen <71623442+Akash-Kumar-Sen@users.noreply.github.com> Co-authored-by: Simon Charette <charette.s@gmail.com>
2025-08-28Refs #27222 -- Implemented ↵Simon Charette
BaseDatabaseOperations.return_insert_columns()/fetch_returned_insert_rows().
2025-08-12Remove unused OneToOneField from DatabaseWrapper.data_types.Tim Graham
OneToOneField uses the type of the related field.
2025-07-23Refs #36500 -- Rewrapped long docstrings and block comments via a script.django-bot
Rewrapped long docstrings and block comments to 79 characters + newline using script from https://github.com/medmunds/autofix-w505.
2025-05-20Fixed #34262 -- Added support for AnyValue for SQLite, MySQL, Oracle, and ↵ontowhee
Postgresql 16+. Thanks Simon Charette for the guidance and review. Thanks Tim Schilling for the documentation review. Thanks David Wobrock for investigation and solution proposals.
2025-05-14Fixed #36085 -- Added JSONField support for negative array indexing on SQLite.savanto
2025-04-30Refs #36052, #32234 -- Removed create_test_table_with_composite_primary_key ↵Simon Charette
flag in favor of using CompositePrimaryKey. Now that Django properly supports creating models with composite primary keys, the tests should use a `CompositePrimaryKey` field instead of a feature flag to inline backend specific SQL for creating a composite PK. Specifcially, the inspectdb's test_composite_primary_key was adjusted to use schema editor instead of per-backend raw SQL.
2025-03-31Refs #28909 -- Simplified code using unpacking generalizations.Aarni Koskela
2025-03-17Fixed #33537 -- Made test database cloning on MySQL reraise unexpected errors.Mariusz Felisiak
Thanks Faakhir Zahid and Stephen Finucane for the initial patch. Thanks Simon Charette for the review.
2025-03-09Fixed #35487 -- Removed CASCADE from RemoveField() on PostgreSQL.petr.prikryl
Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com> Co-authored-by: Adam Johnson <me@adamj.eu> Co-authored-by: Sarah Boyce <42296566+sarahboyce@users.noreply.github.com>
2025-03-03Fixed #35444 -- Added generic support for Aggregate.order_by.Chris Muthig
This moves the behaviors of `order_by` used in Postgres aggregates into the `Aggregate` class. This allows for creating aggregate functions that support this behavior across all database engines. This is shown by moving the `StringAgg` class into the shared `aggregates` module and adding support for all databases. The Postgres `StringAgg` class is now a thin wrapper on the new shared `StringAgg` class. Thank you Simon Charette for the review.
2025-02-13Refs #36181 -- Removed the obsolete SubqueryConstraint machinery.Simon Charette
Adding proper support for subquery right-hand-sides to TupleIn made it obsolete.
2025-02-09Fixed #36105 -- Dropped support for MariaDB 10.5.Mariusz Felisiak
2025-01-28Refs #36005 -- Bumped minimum supported versions of 3rd-party packages.Mariusz Felisiak
This bumps minimum supported versions of 3rd-party packages to the first releases to support Python 3.12.
2025-01-10Refs #36064 -- Added Model.has_db_default() to encapsulate NOT_PROVIDED checks.Simon Charette
This avoids many awkward checks against NOT_PROVIDED and provides symmetry with Field.has_default() which is also the reason why it wasn't made a property.
2024-12-09Refs #35982 -- Made BaseDatabaseOperations.adapt_decimalfield_value() a no-op.Simon Charette
2024-11-18Fixed #18392 -- Changed default mysql encoding to "utf8mb4".Ben Cail
2024-05-03Fixed #35422 -- Fixed migrations crash when altering GeneratedField ↵Mariusz Felisiak
referencing rename field. Thanks Sarah Boyce for the report and Simon Charette for the implementation idea.
2024-03-14Refs #35295 -- Added BaseDatabaseOperations.bulk_insert_sql().Mariusz Felisiak
Co-authored-by: Nick Pope <nick@nickpope.me.uk>
2024-01-26Applied Black's 2024 stable style.Mariusz Felisiak
https://github.com/psf/black/releases/tag/24.1.0
2023-12-14Fixed #35000 -- Skipped declaring empty string defaults on BLOB/TEXT field ↵Tobias Krönke
on MySQL. Empty string defaults are redundant on MySQL and prevent use of ALGORITHM=INSTANT.
2023-11-27Fixed #34992 -- Fixed DatabaseFeatures.allows_group_by_selected_pks on ↵Nathaniel Conroy
MariaDB with ONLY_FULL_GROUP_BY sql mode. Regression in 041551d716b69ee7c81199eee86a2d10a72e15ab.
2023-11-02Refs #31300 -- Allowed testing GeneratedField without collation.Tim Graham
CockroachDB and Snowflake don't support it.
2023-09-19Fixed #34850 -- Dropped support for MariaDB 10.4.Mariusz Felisiak
2023-09-07Fixed #31300 -- Added GeneratedField model field.Jeremy Nauta
Thanks Adam Johnson and Paolo Melchiorre for reviews. Co-Authored-By: Lily Foote <code@lilyf.org> Co-Authored-By: Mariusz Felisiak <felisiak.mariusz@gmail.com>
2023-08-30Fixed #34799 -- Made MySQL introspection skip cross-database relations.John Whitman
2023-08-03Refs #33713 -- Removed unnecessary version check in ↵Mariusz Felisiak
DatabaseFeatures.update_can_self_select on MariaDB. Follow up to 19297de2fe5a9c47e471c64249366f39fe12f16a.
2023-08-03Fixed #34761 -- Dropped support for MySQL < 8.0.11.Mariusz Felisiak
2023-08-02Fixed #33507 -- Used UUID data type on MariaDB 10.7+.Albert Defler
Co-Authored-By: Mariusz Felisiak <felisiak.mariusz@gmail.com>
2023-05-12Fixed #470 -- Added support for database defaults on fields.Ian Foote
Special thanks to Hannes Ljungberg for finding multiple implementation gaps. Thanks also to Simon Charette, Adam Johnson, and Mariusz Felisiak for reviews.
2023-05-10Fixed #34553 -- Fixed improper % escaping of literal in constraints.Simon Charette
Proper escaping of % in string literals used when defining constaints was attempted (a8b3f96f6) by overriding quote_value of Postgres and Oracle schema editor. The same approach was used when adding support for constraints to the MySQL/MariaDB backend (1fc2c70). Later on it was discovered that this approach was not appropriate and that a preferable one was to pass params=None when executing the constraint creation DDL to avoid any form of interpolation in the first place (42e8cf47). When the second patch was applied the corrective of the first were not removed which caused % literals to be unnecessary doubled. This flew under the radar because the existings test were crafted in a way that consecutive %% didn't catch regressions. This commit introduces an extra test for __exact lookups which highlights more adequately % doubling problems but also adjust a previous __endswith test to cover % doubling problems (%\% -> %%\%%). Thanks Thomas Kolar for the report. Refs #32369, #30408, #30593.
2023-05-03Fixed #34523 -- Fixed TransactionManagementError in ↵Mariusz Felisiak
QuerySet.update_or_create() with MyISAM storage engine. QuerySet.update_or_create() uses nested atomic to handle possible integrity errors taking savepoints as way to mark back the connection as usable. Savepoints are not returned when uses_savepoints/can_release_savepoints feature flags are set to False. As a consequence, QuerySet.update_or_create() assumed the outer atomic block is tainted and raised TransactionManagementError. This commit partly reverts 331a460f8f2e4f447b68fba491464b68c9b21fd1. Thanks gatello-s for the report.
2023-05-01Fixed #33759 -- Avoided unnecessary subquery in QuerySet.delete() with ↵4the4ryushin
self-referential subqueries if supported.
2023-03-18Fixed #34421 -- Fixed QuerySet.update() on querysets in descending order by ↵hb6h057
annotations.
2023-03-02Refs #34320 -- Stopped recreating check constraints when renaming fields.Mariusz Felisiak
This also fixes test_rename_field_with_check_to_truncated_name() on MariaDB 10.5.2+ as ALTER TABLE ... RENAME COLUMN statement doesn't rename inline constraints.
2023-02-21Refs #31445 -- Added test for nesting QuerySet.union().Mariusz Felisiak
This was fixed in MySQL 8.0.31.
2023-02-01Refs #33476 -- Applied Black's 2023 stable style.David Smith
Black 23.1.0 is released which, as the first release of the year, introduces the 2023 stable style. This incorporates most of last year's preview style. https://github.com/psf/black/releases/tag/23.1.0
2023-01-31Fixed #34304 -- Made MySQL's SchemaEditor.remove_constraint() don't create ↵sag᠎e
foreign key index when unique constraint is ignored. Regression in b731e8841558ee4caaba766c83f34ea9c7004f8b.
2023-01-17Fixed #34255 -- Made PostgreSQL backend use client-side parameters binding ↵Mariusz Felisiak
with psycopg version 3. Thanks Guillaume Andreu Sabater for the report. Co-authored-by: Florian Apolloner <apollo13@users.noreply.github.com>
2023-01-05Refs #32355 -- Bumped mysqlclient requirement to >= 1.4.3.Mariusz Felisiak
mysqlclient 1.4.3 is the first release to support Python 3.8.
2022-12-28Fixed #18468 -- Added support for comments on columns and tables.kimsoungryoul
Thanks Jared Chung, Tom Carrick, David Smith, Nick Pope, and Mariusz Felisiak for reviews. Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com> Co-authored-by: Nick Pope <nick@nickpope.me.uk>
2022-12-22Fixed #34219 -- Preserved Char/TextField.db_collation when altering column type.Mariusz Felisiak
This moves setting a database collation to the column type alteration as both must be set at the same time. This should also avoid another layer of the column type alteration when adding database comments support (#18468).