Opened 9 years ago

Last modified 4 years ago

#25287 new New feature

Multiplying and dividing connectors are not supported by sqlite backed. — at Initial Version

Reported by: Ahmet DAL Owned by: nobody
Component: Database layer (models, ORM) Version: 3.0
Severity: Normal Keywords: sqlite3, mysql, combine_duration_expression, F expressions,
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

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.

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top