1
0
mirror of https://github.com/django/django.git synced 2025-11-07 07:15:35 +00:00

Fixed #35111 -- Fixed compilation of DateField __in/__range rhs on SQLite and MySQL.

Also removed tests that ensured that adapt_(date)timefield backend
operations where able to deal with expressions when it's not the case
for any other adapt methods.
This commit is contained in:
Simon Charette
2024-01-13 16:16:58 -05:00
committed by Mariusz Felisiak
parent 561f770415
commit 0fcee1676c
6 changed files with 23 additions and 40 deletions

View File

@@ -562,10 +562,6 @@ class BaseDatabaseOperations:
"""
if value is None:
return None
# Expression values are adapted by the database.
if hasattr(value, "resolve_expression"):
return value
return str(value)
def adapt_timefield_value(self, value):
@@ -575,10 +571,6 @@ class BaseDatabaseOperations:
"""
if value is None:
return None
# Expression values are adapted by the database.
if hasattr(value, "resolve_expression"):
return value
if timezone.is_aware(value):
raise ValueError("Django does not support timezone-aware times.")
return str(value)

View File

@@ -590,10 +590,6 @@ END;
if value is None:
return None
# Expression values are adapted by the database.
if hasattr(value, "resolve_expression"):
return value
# oracledb doesn't support tz-aware datetimes
if timezone.is_aware(value):
if settings.USE_TZ:
@@ -610,10 +606,6 @@ END;
if value is None:
return None
# Expression values are adapted by the database.
if hasattr(value, "resolve_expression"):
return value
if isinstance(value, str):
return datetime.datetime.strptime(value, "%H:%M:%S")

View File

@@ -263,10 +263,6 @@ class DatabaseOperations(BaseDatabaseOperations):
if value is None:
return None
# Expression values are adapted by the database.
if hasattr(value, "resolve_expression"):
return value
# SQLite doesn't support tz-aware datetimes
if timezone.is_aware(value):
if settings.USE_TZ:
@@ -283,10 +279,6 @@ class DatabaseOperations(BaseDatabaseOperations):
if value is None:
return None
# Expression values are adapted by the database.
if hasattr(value, "resolve_expression"):
return value
# SQLite doesn't support tz-aware datetimes
if timezone.is_aware(value):
raise ValueError("SQLite backend does not support timezone-aware times.")

View File

@@ -268,11 +268,16 @@ class FieldGetDbPrepValueMixin:
getattr(field, "get_db_prep_value", None)
or self.lhs.output_field.get_db_prep_value
)
if not self.get_db_prep_lookup_value_is_iterable:
value = [value]
return (
"%s",
[get_db_prep_value(v, connection, prepared=True) for v in value]
if self.get_db_prep_lookup_value_is_iterable
else [get_db_prep_value(value, connection, prepared=True)],
[
v
if hasattr(v, "as_sql")
else get_db_prep_value(v, connection, prepared=True)
for v in value
],
)