#25287: Multiplying and dividing connectors are not supported by sqlite backed. -------------------------------------+------------------------------------- Reporter: javrasya | Owner: nobody Type: Bug | Status: new Component: Database layer | Version: 1.8 (models, ORM) | Severity: Normal | Resolution: Keywords: sqlite3, | Triage Stage: combine_duration_expression, F | Unreviewed expressions, | Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+------------------------------------- Changes (by javrasya):
* needs_better_patch: => 0 * needs_tests: => 0 * needs_docs: => 0 Old description: > I have a query using F expressions. When I run this query on PostgreSQL > it works. But in tests with '''sqlite3''', it does not work; > > Here is my complex query. > {{{ > expires = Expire.objects.filter(ticket__date_opened__lte=(datetime.now() > - F("action__percent") * F("action__rule__duration") / 100)) > }}} > > Sqlite backend does not support connector *. When I looked into the code, > it only supports + and - connectors. > > {{{ > DatabaseError: Invalid connector for timedelta: *. > }}} > > {{{ > def combine_duration_expression(self, connector, sub_expressions): > if connector not in ['+', '-']: > raise utils.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) > }}} > > I tried to add * and / operator in the list; no problem occured. I think > this should be fixed simply. New description: I have a query using F expressions. When I run this query on PostgreSQL it works. But in tests with '''sqlite3''', it does not work; Here is my complex query. {{{ expires = Expire.objects.filter(ticket__date_opened__lte=(datetime.now() - F("action__percent") * F("action__rule__duration") / 100)) }}} Sqlite backend does not support connector *. When I looked into the code, it only supports + and - connectors. {{{ DatabaseError: Invalid connector for timedelta: *. }}} {{{ def combine_duration_expression(self, connector, sub_expressions): if connector not in ['+', '-']: raise utils.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) }}} I tried to add * and / operator in the list; no problem occured. I think this can be fixed simply. -- -- Ticket URL: <https://code.djangoproject.com/ticket/25287#comment:1> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/066.be9770aa78690dcd2aaf692f4a364848%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.