Make Cursor.execute() & executemany() raise NotSupportedError

XMLWordPrintableJSON

    • None
    • Python Drivers
    • Not Needed
    • None
    • None
    • None
    • None
    • None
    • None

      Context

      Django provides the following methods to execute raw SQL queries:

      with connection.cursor() as cursor:
          cursor.executemany(query, args)
          cursor.execute(query, args)

      With MongoDB, this crashes:

        File "/home/tim/code/django/tests/backends/tests.py", line 330, in create_squares
          cursor.executemany(query, args)
          ^^^^^^^^^^^^^^^^^^
      AttributeError: 'NoneType' object has no attribute 'executemany'

      Definition of done

      execute() and execute_many() stub methods that raise django.db.NotSupportedError must be added to django-mongodb-backend's Cursor.

      (I believe it's unnecessary to raise errors for the reading methods [fetchone, fetchmany, fetchall, nextset] since these would only be called after the execute methods.)

            Assignee:
            Tim Graham
            Reporter:
            Tim Graham
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: