mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Refs #33476 -- Refactored code to strictly match 88 characters line length.
This commit is contained in:
@@ -512,8 +512,10 @@ class YearLteTests(TestCase):
|
||||
rhs_sql, rhs_params = self.process_rhs(compiler, connection)
|
||||
params = lhs_params + rhs_params + lhs_params + rhs_params
|
||||
return (
|
||||
"%(lhs)s >= str_to_date(concat(%(rhs)s, '-01-01'), '%%%%Y-%%%%m-%%%%d') "
|
||||
"AND %(lhs)s <= str_to_date(concat(%(rhs)s, '-12-31'), '%%%%Y-%%%%m-%%%%d')"
|
||||
"%(lhs)s >= "
|
||||
"str_to_date(concat(%(rhs)s, '-01-01'), '%%%%Y-%%%%m-%%%%d') "
|
||||
"AND %(lhs)s <= "
|
||||
"str_to_date(concat(%(rhs)s, '-12-31'), '%%%%Y-%%%%m-%%%%d')"
|
||||
% {"lhs": lhs_sql, "rhs": rhs_sql},
|
||||
params,
|
||||
)
|
||||
@@ -525,12 +527,12 @@ class YearLteTests(TestCase):
|
||||
finally:
|
||||
delattr(YearExact, "as_" + connection.vendor)
|
||||
try:
|
||||
# The other way is to subclass the original lookup and register the subclassed
|
||||
# lookup instead of the original.
|
||||
# The other way is to subclass the original lookup and register the
|
||||
# subclassed lookup instead of the original.
|
||||
class CustomYearExact(YearExact):
|
||||
# This method should be named "as_mysql" for MySQL, "as_postgresql" for postgres
|
||||
# and so on, but as we don't know which DB we are running on, we need to use
|
||||
# setattr.
|
||||
# This method should be named "as_mysql" for MySQL,
|
||||
# "as_postgresql" for postgres and so on, but as we don't know
|
||||
# which DB we are running on, we need to use setattr.
|
||||
def as_custom_sql(self, compiler, connection):
|
||||
lhs_sql, lhs_params = self.process_lhs(
|
||||
compiler, connection, self.lhs.lhs
|
||||
@@ -538,8 +540,10 @@ class YearLteTests(TestCase):
|
||||
rhs_sql, rhs_params = self.process_rhs(compiler, connection)
|
||||
params = lhs_params + rhs_params + lhs_params + rhs_params
|
||||
return (
|
||||
"%(lhs)s >= str_to_date(CONCAT(%(rhs)s, '-01-01'), '%%%%Y-%%%%m-%%%%d') "
|
||||
"AND %(lhs)s <= str_to_date(CONCAT(%(rhs)s, '-12-31'), '%%%%Y-%%%%m-%%%%d')"
|
||||
"%(lhs)s >= "
|
||||
"str_to_date(CONCAT(%(rhs)s, '-01-01'), '%%%%Y-%%%%m-%%%%d') "
|
||||
"AND %(lhs)s <= "
|
||||
"str_to_date(CONCAT(%(rhs)s, '-12-31'), '%%%%Y-%%%%m-%%%%d')"
|
||||
% {"lhs": lhs_sql, "rhs": rhs_sql},
|
||||
params,
|
||||
)
|
||||
@@ -584,7 +588,10 @@ class LookupTransformCallOrderTests(SimpleTestCase):
|
||||
def test_call_order(self):
|
||||
with register_lookup(models.DateField, TrackCallsYearTransform):
|
||||
# junk lookup - tries lookup, then transform, then fails
|
||||
msg = "Unsupported lookup 'junk' for IntegerField or join on the field not permitted."
|
||||
msg = (
|
||||
"Unsupported lookup 'junk' for IntegerField or join on the field not "
|
||||
"permitted."
|
||||
)
|
||||
with self.assertRaisesMessage(FieldError, msg):
|
||||
Author.objects.filter(birthdate__testyear__junk=2012)
|
||||
self.assertEqual(
|
||||
|
||||
Reference in New Issue
Block a user