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

Mitigate AssertionError for unique constraints #56

Merged
merged 4 commits into from
Jun 3, 2024

Conversation

hab6
Copy link
Contributor

@hab6 hab6 commented May 31, 2024

Description

Additional improvements that follow PR #52, which provided partial relief to address failing tests involving reflection of tables containing unique constraints. More work was needed in overloaded method IngresDialect::get_unique_constraints to return the correct constraint list in a proper format.

It is also worth noting that a few changes to requirements.py to be delivered in this PR should have been included in PR #52. Without those changes, the code delivered in PR #52 will still have problems.

Refactoring of get_unique_constraints

The logic of get_unique_constraints was refactored so that this method is now returns a list of dictionaries, with each dictionary containing the name and column(s) of a unique constraint.

It is worth noting that if the constraint name was auto-generated by the SQL engine (versus explicitly named in the application's CREATE TABLE statement), the constraint name is returned as None (following the example of the SQLite dialect).

Example of constraint data returned from IngresDialect::get_unique_constraints

[ {'name': None, 'column_names': ['data']},
  {'name': 'zz_dingalings_multiple', 'column_names': ['address_id', 'dingaling_id']},
  {'name': 'user_tmp_uq_main', 'column_names': ['name']} ]

Testing

  1. Configure SQLAlchemy dialect compliance suite testing according to the instructions in README.testsuite.md
  2. Run unique_constraints tests:
    pytest --db ingres_odbc -vv --maxfail=100 .\test\dialect\test_suite.py -k "test_get_multi_unique_constraints" --tb=no

Impact of Fix

Results when running test_get_multi_unique_constraints of the SQLAlchemy dialect compliance suite.

Results Passed Failed
Before Changes 26 16
After Changes 41 1

Environment

Microsoft Windows [Version 10.0.19045.4291]
Python 3.10.7
mock              5.1.0
packaging         24.0
pip               24.0
pluggy            1.5.0
pyodbc            5.1.0
pyproject-api     1.6.1
pypyodbc          1.3.6
pytest            8.2.1
setuptools        63.2.0
SQLAlchemy        2.0.29.dev0
sqlalchemy-ingres 0.0.7.dev5
tox               4.15.0
typing_extensions 4.12.0
virtualenv        20.26.2

Internal ticket II-14398

@hab6 hab6 merged commit 7f915b4 into master Jun 3, 2024
@hab6 hab6 deleted the hab6-unique-constraints-improvements branch June 3, 2024 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants