summaryrefslogtreecommitdiff
path: root/django/db/backends/mysql/operations.py
AgeCommit message (Collapse)Author
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.
2025-10-27Fixed #36624 -- Dropped support for MySQL < 8.4.Mariusz Felisiak
2025-08-28Refs #27222 -- Implemented ↵Simon Charette
BaseDatabaseOperations.return_insert_columns()/fetch_returned_insert_rows().
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.
2024-12-09Refs #35982 -- Made BaseDatabaseOperations.adapt_decimalfield_value() a no-op.Simon Charette
2024-03-14Refs #35295 -- Added BaseDatabaseOperations.bulk_insert_sql().Mariusz Felisiak
Co-authored-by: Nick Pope <nick@nickpope.me.uk>
2023-09-19Fixed #34850 -- Dropped support for MariaDB 10.4.Mariusz Felisiak
2022-07-09Refs CVE-2022-34265 -- Unified DatabaseOperations._convert_*_to_tz() hook names.Mariusz Felisiak
2022-07-08Fixed #33718 -- Dropped support for MySQL 5.7.Mariusz Felisiak
2022-07-06Refs CVE-2022-34265 -- Properly escaped Extract() and Trunc() parameters.Simon Charette
Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
2022-05-18Fixed #33713 -- Dropped support for MariaDB 10.3.Mariusz Felisiak
2022-02-07Refs #33476 -- Refactored code to strictly match 88 characters line length.Mariusz Felisiak
2022-02-07Refs #33476 -- Reformatted code with Black.django-bot
2022-02-03Refs #33476 -- Refactored problematic code before reformatting by Black.Mariusz Felisiak
In these cases Black produces unexpected results, e.g. def make_random_password( self, length=10, allowed_chars='abcdefghjkmnpqrstuvwxyz' 'ABCDEFGHJKLMNPQRSTUVWXYZ' '23456789', ): or cursor.execute(""" SELECT ... """, [table name], )
2022-01-19Fixed #31685 -- Added support for updating conflicts to QuerySet.bulk_create().sean_c_hsu
Thanks Florian Apolloner, Chris Jerdonek, Hannes Ljungberg, Nick Pope, and Mariusz Felisiak for reviews.
2021-11-12Fixed #33279 -- Fixed handling time zones with "-" sign in names.Can Sarigol
Thanks yakimka for the report. Regression in fde9b7d35e4e185903cc14aa587ca870037941b1.
2021-11-02Fixed #32691 -- Made Exact lookup on BooleanFields compare directly to a ↵Roman
boolean value on MySQL. Performance regression in 37e6c5b79bd0529a3c85b8c478e4002fd33a2a1d. Thanks Todor Velichkov for the report. Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
2021-06-01Fixed #32793 -- Fixed loss of precision for temporal operations with ↵Mariusz Felisiak
DecimalFields on MySQL. Regression in 1e38f1191de21b6e96736f58df57dfb851a28c1f. Thanks Mohsen Tamiz for the report.
2021-05-07Fixed #32699 -- Fixed comparing to TruncTime() with 0 microseconds on MySQL.Alex Hill
2021-01-14Refs #31369 -- Removed models.NullBooleanField per deprecation timeline.Mariusz Felisiak
2020-10-14Fixed #31640 -- Made Trunc() truncate datetimes to Date/TimeField in a ↵David-Wobrock
specific timezone.
2020-10-02Fixed #32060 -- Added Random database function.Nick Pope
2020-09-09Fixed #31987 -- Fixed Cast() with DurationField on MySQL.Petr Čermák
2020-07-20Fixed #17653 -- Allowed using zero as AutoFields value on MySQL if ↵Mariusz Felisiak
NO_AUTO_VALUE_ON_ZERO SQL mode is enabled.
2020-06-30Fixed #28925 -- Fixed durations-only expressions crash on SQLite and MySQL.Sergey Fedoseev
This removes also unused DatabaseOperations.date_interval_sql().
2020-05-19Fixed #31578 -- Dropped support for MySQL 5.6.Mariusz Felisiak
2020-05-08Fixed #12990, Refs #27694 -- Added JSONField model field.sage
Thanks to Adam Johnson, Carlton Gibson, Mariusz Felisiak, and Raphael Michel for mentoring this Google Summer of Code 2019 project and everyone else who helped with the patch. Special thanks to Mads Jensen, Nick Pope, and Simon Charette for extensive reviews. Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
2020-04-17Fixed #31473 -- Made sql_flush() use RESTART IDENTITY to reset sequences on ↵Jon Dufresne
PostgreSQL. The sql_flush() positional argument sequences is replaced by the boolean keyword-only argument reset_sequences. This ensures that the old function signature can't be used by mistake when upgrading Django. When the new argument is True, the sequences of the truncated tables will reset. Using a single boolean value, rather than a list, allows making a binary yes/no choice as to whether to reset all sequences rather than a working on a completely different set.
2020-04-02Fixed #31275 -- Optimized sql_flush() without resetting sequences on MySQL.c-bata
Co-Authored-By: Simon Charette <charettes@users.noreply.github.com>
2020-03-31Fixed #31403 -- Added support for returning fields from INSERT statements on ↵Adam Johnson
MariaDB 10.5+.
2020-03-25Fixed #31396 -- Added binary XOR operator to F expressions.Hannes Ljungberg
2020-02-27Fixed #31312 -- Properly ordered temporal subtraction params on MySQL.Simon Charette
Regression in 9bcbcd599abac91ea853b2fe10b784ba32df043e. Thanks rick2ricks for the report.
2020-01-03Fixed #31133 -- Fixed crash when subtracting against a subquery annotation.Simon Charette
The subtract_temporals() database operation was not handling expressions returning SQL params in mixed database types. Regression in 35431298226165986ad07e91f9d3aca721ff38ec. Thanks Reupen Shah for the report.
2019-11-19Fixed #30987 -- Added models.PositiveBigIntegerField.Caio Ariede
2019-10-24Refs #30897 -- Added support for ANALYZE option to Queryset.explain() on ↵Nick Pope
MariaDB and MySQL 8.0.18+.
2019-10-24Refs #30897 -- Added support for TREE format to Queryset.explain() on MySQL ↵Nick Pope
8.0.16+.
2019-10-02Fixed #30821 -- Added ExtractIsoWeekYear database function and iso_week_day ↵Anatol Ulrich
lookup.
2019-08-02Fixed #30661 -- Added models.SmallAutoField.Nick Pope
2019-06-13Fixed #30128 -- Fixed handling timedelta timezone in database functions.can
2019-04-21Refs #30380 -- Used cursor._executed in ↵Mariusz Felisiak
DatabaseOperations.last_executed_query() on MySQL. Regression in a41b09266dcdd01036d59d76fe926fe0386aaade. Thanks Tobias Krönke for the report.
2019-04-19Fixed #30380 -- Handled bytes in MySQL backend for PyMySQL support.Mariusz Felisiak
This commit partly reverts efd8a82e268a82b3ad0be77bd5b4548c30bcb4d7.
2019-04-08Fixed #28373 -- Used connection timezone instead of UTC when making dates ↵can
timezone-aware on MySQL, SQLite, and Oracle. Thanks vtalpaert for the initial patch. Co-Authored-By: Mariusz Felisiak <felisiak.mariusz@gmail.com>
2019-02-09Removed uneeded generator expressions and list comprehensions.Sergey Fedoseev
2018-12-05Fixed #30013 -- Fixed DatabaseOperations.last_executed_query() with ↵Tim Graham
mysqlclient 1.3.14+.
2018-10-15Fixed #29845 -- Fixed Cast crash on MySQL when casting to DecimalField.Mariusz Felisiak
2018-10-09Simplified handling of DurationField values on MySQL/MariaDB.Sergey Fedoseev
2018-10-03Refs #27795 -- Removed force_bytes() usage in MySQL backend.Jon Dufresne
The mysqlclient cursor attribute `_last_executed` is always stored as bytes. Decode it. TextField values are already type str. No need to decode.
2018-09-26Refs #29784 -- Switched to https:// links where available.Jon Dufresne
2018-08-18Fixed #28649 -- Added ExtractIsoYear database function and iso_year lookup.Sigurd Ljødal
2018-08-03Fixed #28668 -- Allowed QuerySet.bulk_create() to ignore insert conflicts.Tom