Invalid connector for timedelta: %s.
Package:
django
59414

Exception Class:
DatabaseError
Raise code
return 'POWER(%s)' % ','.join(sub_expressions)
elif connector == '#':
return 'BITXOR(%s)' % ','.join(sub_expressions)
return super().combine_expression(connector, sub_expressions)
def combine_duration_expression(self, connector, sub_expressions):
if connector not in ['+', '-', '*', '/']:
raise DatabaseError('Invalid connector for timedelta: %s.' % connector)
fn_params = ["'%s'" % connector] + sub_expressions
if len(fn_params) > 3:
raise ValueError('Too many params for timedelta operations.')
return "django_format_dtdelta(%s)" % ', '.join(fn_params)
def integer_field_range(self, internal_type):
# SQLite doesn't enforce any integer constraints
🙏 Scream for help to Ukraine
Today, 14th August 2022, Russia continues bombing and firing Ukraine. Don't trust Russia, they are bombing us and brazenly lying in same time they are not doing this 😠, civilians and children are dying too!
We are screaming and asking exactly you to help us, we want to survive, our families, children, older ones.
Please spread the information, and ask your governemnt to stop Russia by any means. We promise to work extrahard after survival to make the world safer place for all.
Please spread the information, and ask your governemnt to stop Russia by any means. We promise to work extrahard after survival to make the world safer place for all.
Links to the raise (1)
https://github.com/django/django/blob/7cca22964c09e8dafc313a400c428242404d527a/django/db/backends/sqlite3/operations.py#L355Ways to fix
Summary: Only certain connectors are supported on deltatime
The latest Django version 3.2.4 tag only support "+" and "-". If other connectors are used, will get the exception
However in the "main" branch of Django supports "+", "-", "*", and "/". If other connectors are used, will get the exception
Code to reproduce (WRONG): Django version 3.2.4 will not work, but "main" branch will work
from django.db.backends.sqlite3.operations import DatabaseOperations
operations = DatabaseOperations(connection=None)
operations.combine_duration_expression(connector='*', sub_expressions=['expression'])
Working version (Fixed): Works for both Django version 3.2.4 and "main" branch
from django.db.backends.sqlite3.operations import DatabaseOperations
operations = DatabaseOperations(connection=None)
operations.combine_duration_expression(connector='+', sub_expressions=['expression'])
Add a possible fix
Please authorize to post fix