Opened 10 years ago
Last modified 4 years ago
#25287 new New feature
Multiplying and dividing connectors are not supported by sqlite backed. — at Version 1
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 |
Pull Requests: | |||
Description (last modified by ) ¶
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.
According to the ticket's flags, the next step(s) to move this issue forward are:
- To provide a patch by sending a pull request. Claim the ticket when you start working so that someone else doesn't duplicate effort. Before sending a pull request, review your work against the patch review checklist. Check the "Has patch" flag on the ticket after sending a pull request and include a link to the pull request in the ticket comment when making that update. The usual format is:
[https://github.com/django/django/pull/#### PR]
.
Note:
See TracTickets
for help on using tickets.