exception NotImplementedError raised when using MySQL

Bug #797290 reported by m4v
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Storm
New
Undecided
Unassigned

Bug Description

This is my console capture:

In [3]: import storm

In [4]: storm.version
Out[4]: '0.18.0.99'

In [5]: from storm.locals import *

In [6]: store = Store(create_database("mysql://foo:bar@localhost/test"))

In [7]: store.execute('drop database test')
Out[7]: <storm.databases.mysql.MySQLResult object at 0x2d4cb10>

In [8]: store.execute('create database test')
Out[8]: <storm.databases.mysql.MySQLResult object at 0x2d4cc90>

In [9]: store.execute('use test')
Out[9]: <storm.databases.mysql.MySQLResult object at 0x2d4ce50>

In [10]: class Test(object):
   ....: __storm_table__ = "test"
   ....: id = Int(primary=True)
   ....: name = Unicode()
   ....:
   ....:

In [11]: store.execute("create table test (id INTEGER PRIMARY KEY, name TEXT)")
Out[11]: <storm.databases.mysql.MySQLResult object at 0x2d5b0d0>

In [12]: t = Test()

In [13]: t.name = u"foo"

In [14]: store.add(t)
Out[14]: <__main__.Test object at 0x2d5b150>

In [15]: store.flush()
/home/m4v/dev/install/storm/lib/python2.7/site-packages/storm/database.py:366: Warning: Field 'id' doesn't have a default value
  return function(*args, **kwargs)
---------------------------------------------------------------------------
NotImplementedError Traceback (most recent call last)

/home/m4v/dev/install/storm/<ipython console> in <module>()

/home/m4v/dev/install/storm/lib/python2.7/site-packages/storm/store.pyc in flush(self)
    483 del sorted_dirty[i]
    484 self._dirty.pop(obj_info, None)
--> 485 self._flush_one(obj_info)
    486
    487 self._order.clear()

/home/m4v/dev/install/storm/lib/python2.7/site-packages/storm/store.pyc in _flush_one(self, obj_info)
    526 obj_info.pop("invalidated", None)
    527
--> 528 self._fill_missing_values(obj_info, obj_info.primary_vars, result)
    529
    530 self._enable_change_notification(obj_info)

/home/m4v/dev/install/storm/lib/python2.7/site-packages/storm/store.pyc in _fill_missing_values(self, obj_info, primary_vars, result)
    646 if missing_columns:
    647 where = result.get_insert_identity(cls_info.primary_key,
--> 648 primary_vars)
    649 result = self._connection.execute(Select(missing_columns, where))
    650 self._set_values(obj_info, missing_columns,

/home/m4v/dev/install/storm/lib/python2.7/site-packages/storm/database.pyc in get_insert_identity(self, primary_columns, primary_variables)
    139 @rtype: L{storm.expr.Expr}
    140 """
--> 141 raise NotImplementedError
    142
    143 @staticmethod

NotImplementedError:

----
Storm tests output:

python setup.py build_ext -i
/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'include_package_data'
  warnings.warn(msg)
/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'zip_safe'
  warnings.warn(msg)
running build_ext
# Run the tests once with C extensions and once without them.
python test && STORM_CEXTENSIONS=0 python test
..............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................E................................................................................................sssssssssssssssss...............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ssssssssssssssssssssssssssssssssss.....................sssssssssss
======================================================================
ERROR: test_connection_raw_execute_error (tests.databases.postgres.PostgresTimeoutTracerTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/m4v/dev/storm/tests/mocker.py", line 102, in test_method_wrapper
    result = test_method()
  File "/home/m4v/dev/storm/tests/databases/postgres.py", line 568, in test_connection_raw_execute_error
    self.connection.execute(statement)
  File "/home/m4v/dev/storm/storm/databases/postgres.py", line 249, in execute
    return Connection.execute(self, statement, params, noresult)
  File "/home/m4v/dev/storm/storm/database.py", line 237, in execute
    raw_cursor = self.raw_execute(statement, params)
  File "/home/m4v/dev/storm/storm/databases/postgres.py", line 259, in raw_execute
    return Connection.raw_execute(self, statement, params)
  File "/home/m4v/dev/storm/storm/database.py", line 321, in raw_execute
    self._check_disconnect(raw_cursor.execute, *args)
  File "/home/m4v/dev/storm/storm/database.py", line 366, in _check_disconnect
    return function(*args, **kwargs)
QueryCanceledError: cancelando consulta debido a que se agotó el tiempo de espera de sentencias

----------------------------------------------------------------------
Ran 2529 tests in 1155.542s

FAILED (errors=1, skipped=62)
make: *** [check] Error 1

Revision history for this message
James Henstridge (jamesh) wrote :

If you want an automatically allocated primary key with MySQL, you need to set the AUTO_INCREMENT flag for the primary key column. MySQL doesn't provide a way to locate the just-inserted row if this is not the case, which is causing things to fall through to a code path that is not implemented.

As far as the failing test, it looks like the timeout code is checking for a particular string in the exception message, which is not matching due to locale differences. There is a comment suggesting we use QueryCanceledError once the version of psycopg2 where it was introduced is used widely enough. Perhaps we are at that point now.

Revision history for this message
Stuart Bishop (stub) wrote :

I've opened Bug #855299 on the PostgreSQL issue.

Revision history for this message
m4v (m4v) wrote :

Thanks.

I did find out sometime later that with AUTO_INCREMENT the code worked, but I didn't know if that was the correct way of using Storm with MySQL. It might be worth noting this in the documentation somewhere, like adding a functional MySQL example or something. As someone coming from sqlite, using AUTO_INCREMENT wasn't obvious to me and when I asked in #storm people were clueless as well.

Revision history for this message
James Henstridge (jamesh) wrote :

Stuart: this test failure is not related to disconnections: instead, it is for the case where the database notifies the client that a query has been cancelled (i.e. timeout processing).

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.