HazyResearch / fonduer

A knowledge base construction engine for richly formatted data
https://fonduer.readthedocs.io/
MIT License
409 stars 77 forks source link

Test code "test_postgres.py" failes with sqlalchemy delete method #538

Closed YasushiMiyata closed 3 years ago

YasushiMiyata commented 3 years ago

Description of the bug

In running the test code "test_postgres.py::test_cand_gen_cascading_delete", program fails by "sqlalchemy.exc.ProgrammingError". Error message is;

E       sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedTable) missing FROM-clause entry for table "candidate"
E       LINE 1: ...E FROM part_temp WHERE part_temp.id = 2 RETURNING candidate....
E                                                                    ^
E       
E       [SQL: DELETE FROM part_temp WHERE part_temp.id = %(id_1)s RETURNING candidate.id]
E       [parameters: {'id_1': 2}]
E       (Background on this error at: http://sqlalche.me/e/14/f405)

To Reproduce

Steps to reproduce the behavior:

  1. Execute pytest test_postgres.py::test_cand_gen_cascading_delete or ci after pull request.

Expected behavior

Test completes with no error.

Error Logs/Screenshots

        # Test that deletion of a Candidate does not delete the Mention
        x = session.query(PartTemp).first()
>       session.query(PartTemp).filter_by(id=x.id).delete(synchronize_session="fetch")

tests/test_postgres.py:119: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../../test0426/py38fonduer/lib/python3.8/site-packages/sqlalchemy/orm/query.py:3124: in delete
    result = self.session.execute(
../../test0426/py38fonduer/lib/python3.8/site-packages/sqlalchemy/orm/session.py:1670: in execute
    result = conn._execute_20(statement, params or {}, execution_options)
../../test0426/py38fonduer/lib/python3.8/site-packages/sqlalchemy/engine/base.py:1521: in _execute_20
    return meth(self, args_10style, kwargs_10style, execution_options)
../../test0426/py38fonduer/lib/python3.8/site-packages/sqlalchemy/sql/elements.py:313: in _execute_on_connection
    return connection._execute_clauseelement(
../../test0426/py38fonduer/lib/python3.8/site-packages/sqlalchemy/engine/base.py:1390: in _execute_clauseelement
    ret = self._execute_context(
../../test0426/py38fonduer/lib/python3.8/site-packages/sqlalchemy/engine/base.py:1749: in _execute_context
    self._handle_dbapi_exception(
../../test0426/py38fonduer/lib/python3.8/site-packages/sqlalchemy/engine/base.py:1930: in _handle_dbapi_exception
    util.raise_(
../../test0426/py38fonduer/lib/python3.8/site-packages/sqlalchemy/util/compat.py:211: in raise_
    raise exception
../../test0426/py38fonduer/lib/python3.8/site-packages/sqlalchemy/engine/base.py:1706: in _execute_context
    self.dialect.do_execute(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <sqlalchemy.dialects.postgresql.psycopg2.PGDialect_psycopg2 object at 0x7f39353b8400>
cursor = <cursor object at 0x7f392ba5a7c0; closed: -1>
statement = 'DELETE FROM part_temp WHERE part_temp.id = %(id_1)s RETURNING candidate.id', parameters = {'id_1': 2}
context = <sqlalchemy.dialects.postgresql.psycopg2.PGExecutionContext_psycopg2 object at 0x7f392b3380a0>

    def do_execute(self, cursor, statement, parameters, context=None):
>       cursor.execute(statement, parameters)
E       sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedTable) missing FROM-clause entry for table "candidate"
E       LINE 1: ...E FROM part_temp WHERE part_temp.id = 2 RETURNING candidate....
E                                                                    ^
E       
E       [SQL: DELETE FROM part_temp WHERE part_temp.id = %(id_1)s RETURNING candidate.id]
E       [parameters: {'id_1': 2}]
E       (Background on this error at: http://sqlalche.me/e/14/f405)

../../test0426/py38fonduer/lib/python3.8/site-packages/sqlalchemy/engine/default.py:716: ProgrammingError

Environment (please complete the following information)

Additional context

No error occurs with python 3.6.9