Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve on error handling when column is not found #9

Open
ivergara opened this issue Sep 22, 2021 · 0 comments
Open

Improve on error handling when column is not found #9

ivergara opened this issue Sep 22, 2021 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@ivergara
Copy link
Collaborator

When a column specified in a constraint is not found, an unmanaged exception is shown that doesn't help in understanding what's the problem

______ test_constraint[UniquesSubset::X.X.X] ______

constraint = <dbcheck.constraints.uniques.UniquesSubset object at 0x7f9be45be730>
engine = Engine(postgresql://XXXX:***@XXXXXXXXXXXX:5432/health)

    @pytest.mark.parametrize("constraint", get_constraints(SCHEMA, OLD_SCHEMA), ids=idfn)
    def test_constraint(constraint, engine):
>       test_result = constraint.test(engine)

test_data.py:59: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
X/lib/python3.8/site-packages/dbcheck/constraints/base.py:178: in test
    value_factual = self.get_factual_value(engine)
X/lib/python3.8/site-packages/dbcheck/constraints/base.py:110: in get_factual_value
    factual_value, factual_selections = self.retrieve(engine, self.ref)
X/lib/python3.8/site-packages/dbcheck/constraints/uniques.py:94: in retrieve
    uniques, selection = db_access.get_uniques(engine, ref)
X/lib/python3.8/site-packages/dbcheck/db_access.py:377: in get_uniques
    selection = ref.get_selection(engine).alias()
X/lib/python3.8/site-packages/dbcheck/db_access.py:150: in get_selection
    [table.c[column_name] for column_name in self.columns]
X/lib/python3.8/site-packages/dbcheck/db_access.py:150: in <listcomp>
    [table.c[column_name] for column_name in self.columns]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <sqlalchemy.sql.base.ImmutableColumnCollection object at 0x7f9be365e5e0>
key = 'l'

    def __getitem__(self, key):
        try:
>           return self._index[key]
E           KeyError: 'l'

KeyError: 'l' in this case is not very useful, l being the name of the column not found.

@ivergara ivergara added enhancement New feature or request good first issue Good for newcomers labels Sep 22, 2021
@kklein kklein transferred this issue from another repository Apr 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant