Issue #5 wontfix

Failing tests on SA 0.7.1

Martin Bačovský
created an issue

When I run the tests on machine with python 2.7.1 and SQLAlchemy 0.7.1 the tests are failing

{{{

!text

running test running egg_info writing requirements to sqlamp.egg-info/requires.txt writing sqlamp.egg-info/PKG-INFO writing top-level names to sqlamp.egg-info/top_level.txt writing dependency_links to sqlamp.egg-info/dependency_links.txt reading manifest file 'sqlamp.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' writing manifest file 'sqlamp.egg-info/SOURCES.txt' running build_ext test_benchmark (tests.benchmark-tests.BenchmarkTestCase) ... ok _iter_current_next (sqlamp) Doctest: sqlamp._iter_current_next ... ok _recursive_iterator (sqlamp) Doctest: sqlamp._recursive_iterator ... ok inc_path (sqlamp) Doctest: sqlamp.inc_path ... ok /builddir/build/BUILD/sqlamp-0.5.2/tests/doctests.py Doctest: doctests.py ... ok test_ancestors (tests.functional-tests.FunctionalTestCase) ... ok test_children (tests.functional-tests.FunctionalTestCase) ... ok test_declarative (tests.functional-tests.FunctionalTestCase) ... ok test_descendants (tests.functional-tests.FunctionalTestCase) ... ok test_filter_parent (tests.functional-tests.FunctionalTestCase) ... ok test_implicit_pk_fk (tests.functional-tests.FunctionalTestCase) ... ok test_insert_children (tests.functional-tests.FunctionalTestCase) ... ok test_insert_roots (tests.functional-tests.FunctionalTestCase) ... ok test_path_too_deep (tests.functional-tests.FunctionalTestCase) ... ERROR test_query_all_trees (tests.functional-tests.FunctionalTestCase) ... ok test_rebuild_all_trees (tests.functional-tests.FunctionalTestCase) ... ok test_rebuild_subtree (tests.functional-tests.FunctionalTestCase) ... ok test_table_inheritance (tests.functional-tests.FunctionalTestCase) ... ok test_table_inheritance_declarative (tests.functional-tests.FunctionalTestCase) ... ok test_too_many_children_and_last_child_descendants (tests.functional-tests.FunctionalTestCase) ... ERROR test_tree_recursive_iterator (tests.functional-tests.FunctionalTestCase) ... ok ====================================================================== ERROR: test_path_too_deep (tests.functional-tests.FunctionalTestCase)


Traceback (most recent call last): File "/builddir/build/BUILD/sqlamp-0.5.2/tests/functional-tests.py", line 259, in test_path_too_deep self.assertRaises(sqlamp.PathTooDeepError, self.sess.flush) File "/usr/lib64/python2.7/unittest/case.py", line 471, in assertRaises callableObj(args, kwargs) File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/session.py", line 1473, in flush self.flush(objects) File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/session.py", line 1542, in _flush flush_context.execute() File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/unitofwork.py", line 322, in execute n.execute_aggregate(self, set) File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/unitofwork.py", line 553, in execute_aggregate uow) File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.py", line 2163, in _save_obj execute(statement, params) File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1358, in execute params) File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1491, in _execute_clauseelement compiled_sql, distilled_params File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1558, in _execute_context None, None) File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1554, in _execute_context context = constructor(dialect, self, conn, args) File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/default.py", line 448, in _init_compiled param.append(processorskey) File "/usr/lib64/python2.7/site-packages/sqlalchemy/types.py", line 542, in process return process_param(value, dialect) File "/builddir/build/BUILD/sqlamp-0.5.2/sqlamp/init.py", line 353, in process_bind_param return value.query_result['path'] File "/builddir/build/BUILD/sqlamp-0.5.2/sqlamp/init.py", line 325, in query_result self._perform_query() File "/builddir/build/BUILD/sqlamp-0.5.2/sqlamp/init.py", line 313, in _perform_query raise PathTooDeepError() StatementError: 'INSERT INTO tbl (name, parent_id, mp_path, mp_depth, mp_tree_id) VALUES (?, ?, ?, ?, ?)' [{'mp_path': <sqlamp._InsertionsParamsSelector object at 0x2838590>, 'parent_id': 128, 'mp_tree_id': <sqlamp._InsertionsParamsSelector object at 0x2838590>, 'name': None, 'mp_depth': <sqlamp._InsertionsParamsSelector object at 0x2838590>}] ====================================================================== ERROR: test_too_many_children_and_last_child_descendants (tests.functional-tests.FunctionalTestCase)


Traceback (most recent call last): File "/builddir/build/BUILD/sqlamp-0.5.2/tests/functional-tests.py", line 240, in test_too_many_children_and_last_child_descendants self.assertRaises(sqlamp.TooManyChildrenError, self.sess.flush) File "/usr/lib64/python2.7/unittest/case.py", line 471, in assertRaises callableObj(args, kwargs) File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/session.py", line 1473, in flush self.flush(objects) File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/session.py", line 1542, in _flush flush_context.execute() File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/unitofwork.py", line 322, in execute n.execute_aggregate(self, set) File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/unitofwork.py", line 553, in execute_aggregate uow) File "/usr/lib64/python2.7/site-packages/sqlalchemy/orm/mapper.py", line 2163, in _save_obj execute(statement, params) File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1358, in execute params) File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1491, in _execute_clauseelement compiled_sql, distilled_params File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1558, in _execute_context None, None) File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1554, in _execute_context context = constructor(dialect, self, conn, args) File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/default.py", line 448, in _init_compiled param.append(processorskey) File "/usr/lib64/python2.7/site-packages/sqlalchemy/types.py", line 542, in process return process_param(value, dialect) File "/builddir/build/BUILD/sqlamp-0.5.2/sqlamp/init.py", line 353, in process_bind_param return value.query_result['path'] File "/builddir/build/BUILD/sqlamp-0.5.2/sqlamp/init.py", line 325, in query_result self._perform_query() File "/builddir/build/BUILD/sqlamp-0.5.2/sqlamp/init.py", line 311, in _perform_query raise TooManyChildrenError() StatementError: 'INSERT INTO tbl (name, parent_id, mp_path, mp_depth, mp_tree_id) VALUES (?, ?, ?, ?, ?)' [{'mp_path': <sqlamp._InsertionsParamsSelector object at 0x2ee2490>, 'parent_id': 1, 'mp_tree_id': <sqlamp._InsertionsParamsSelector object at 0x2ee2490>, 'name': None, 'mp_depth': <sqlamp._InsertionsParamsSelector object at 0x2ee2490>}]


Ran 21 tests in 4.127s FAILED (errors=2)

}}} After some debugging I found out that the expected exceptions TooManyChildrenError and PathTooDeepError are caught and wrapped in StatementError by SA. It is happening in /SQLAlchemy-0.7.1-py2.7-linux-i686.egg/sqlalchemy/engine/base.py in Connection._execute_context() The exception is caught there and _handle_dbapi_exception wraps it. Here I'm not sure if it is bug in SA or in sqlamp and thus where to fix it.

Regards, Martin

Comments (4)

  1. angri repo owner

    Hi Martin,

    please, take a look at this sqlalchemy mailing list thread: http://groups.google.com/group/sqlalchemy/browse_thread/thread/aaa69700a6a57a2b/d2d09c9a9b2fd5b1

    SA 0.7.1 is not fully supported (nor it can be) in a way that raising these exceptions is compatible with SA < 0.7 or SA > 0.7.1 behaviour.

    If in your environment you have to use SA 0.7.1 (and you want to handle TooManyChildrenError and PathTooDeepError) you need to catch StatementError's instead and unwrap them.

  2. Log in to comment