diff --git a/lib/mysql/connector/django/operations.py b/lib/mysql/connector/django/operations.py index 127750db..3c2fec6c 100644 --- a/lib/mysql/connector/django/operations.py +++ b/lib/mysql/connector/django/operations.py @@ -43,6 +43,22 @@ def date_extract_sql(self, lookup_type, field_name): return "EXTRACT({0} FROM {1})".format( lookup_type.upper(), field_name) + def adapt_datetimefield_value(self, value): + if value is None: + return None + + # MySQL doesn't support tz-aware datetimes + if timezone.is_aware(value): + if settings.USE_TZ: + value = timezone.make_naive(value, self.connection.timezone) + else: + raise ValueError("MySQL backend does not support timezone-aware datetimes when USE_TZ is False.") + + if not self.connection.features.supports_microsecond_precision: + value = value.replace(microsecond=0) + + return force_text(value) + def date_trunc_sql(self, lookup_type, field_name): """Returns SQL simulating DATE_TRUNC @@ -218,9 +234,15 @@ def value_to_db_time(self, value): def max_name_length(self): return 64 - def bulk_insert_sql(self, fields, num_values): - items_sql = "({0})".format(", ".join(["%s"] * len(fields))) - return "VALUES " + ", ".join([items_sql] * num_values) + def bulk_insert_sql(self, fields, placeholder_rows): + if django.VERSION < (1, 9): + num_values = placeholder_rows + items_sql = "({0})".format(", ".join(["%s"] * len(fields))) + return "VALUES " + ", ".join([items_sql] * num_values) + else: + placeholder_rows_sql = (", ".join(row) for row in placeholder_rows) + values_sql = ", ".join("(%s)" % sql for sql in placeholder_rows_sql) + return "VALUES " + values_sql if django.VERSION < (1, 8): def year_lookup_bounds(self, value): pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy