Opened 7 years ago

Last modified 7 years ago

#28274 closed Bug

Django OperationalError near "?": Syntax error — at Version 4

Reported by: Adama Camara Owned by: nobody
Component: Database layer (models, ORM) Version: 1.10
Severity: Normal Keywords: SQLite pytest
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Adama Camara)

I am running some test, but I keep getting this error:

self = <django.db.backends.sqlite3.base.SQLiteCursorWrapper object at 0x7f619aa32d38>
query = '        SELECT cust.id, cust.name, inv.currency_id, SUM(inv.total)\n        FROM\n          v3_customer as cust\n    ...        and inv.invoice_date < ?\n        GROUP BY cust.id, inv.currency_id\n        ORDER BY cust.id, inv.currency_id'
params = [(1, 2, 3, 4), '2016-12-08']

    def execute(self, query, params=None):
        if params is None:
            return Database.Cursor.execute(self, query)
        query = self.convert_query(query)
>       return Database.Cursor.execute(self, query, params)
E       django.db.utils.OperationalError: near "?": syntax error

../../../environments/tracerenv/lib/python3.4/site-packages/django/db/backends/sqlite3/base.py:337: OperationalError

When looking at the SQL statements and trying to find the "?" symbol it does not appear:

PRE_INV_Q = """\
        SELECT cust.id, cust.name, inv.currency_id, SUM(inv.total)
        FROM
          v3_customer as cust
          JOIN v3_customerproxy ON cust.id = v3_customerproxy.original_id
          JOIN v3_invoice as inv ON v3_customerproxy.id = inv.customer_id
        WHERE
          cust.id IN %s
          and inv.type = 'i'
          and inv.invoice_date < %s
        GROUP BY cust.id, inv.currency_id
        ORDER BY cust.id, inv.currency_id"""

Could there be some incompatibilities between Postgre and SQLite?

Change History (4)

comment:1 by Adama Camara, 7 years ago

Description: modified (diff)

comment:2 by Adama Camara, 7 years ago

Description: modified (diff)
Type: UncategorizedBug

comment:3 by Adama Camara, 7 years ago

Description: modified (diff)

comment:4 by Adama Camara, 7 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top