-
Notifications
You must be signed in to change notification settings - Fork 4
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
Return only user defined indexes from IngresDialect::get_indexes #60
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good, commit message really should have had the PR text in the commit message for explanation.
I understand this fixes the test suite, I think we should offer an option to return system index information (off by default so test suite just runs). Either connection string option (preferred) or environment variable control..
Thoughts?
lib/sqlalchemy_ingres/base.py
Outdated
@@ -802,6 +802,7 @@ def get_indexes(self, connection, table_name, schema=None, **kw): | |||
WHERE | |||
i.index_name = c.index_name | |||
AND i.index_owner = c.index_owner | |||
AND i.system_use = 'U' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good, I think this should be conditional under user control.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review and suggestion.
Added logic allowing inspection of system generated indexes by setting connection execution option inspect_indexes="ALL"
. The default is to return only user-defined indexes.
Example program to check additional code: inspectIndexes.py.txt
Output:
C:\test\> python inspectIndexes.py MYURL1
Inspect1: [{'name': 'address_idx', 'column_names': ['address_id'], 'unique': False}]
Inspect2: [{'name': 'address_idx', 'column_names': ['address_id'], 'unique': False}, {'name': '$house_u000001eb00000000', 'column_names': ['house_id', 'address_id'], 'unique': True}]
Inspect3: [{'name': 'address_idx', 'column_names': ['address_id'], 'unique': False}]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Thanks for the new feature :-)
Overview
A number of tests in area ComponentReflectionTest::get_multi_indexes of the SQLAlchemy Dialect Compliance Suite fail with an
AssertionError
caused by mismatched actual vs expected results.Stack dumps from running with
pytest
reveal that the test suite expects only user defined indexes to be returned by the get_multi_index tests, whereas the Ingres dialect returns all indexes, including internal indexes defined automatically by the DBMS.Here is a simple generic example, showing creation of a user index versus a system generated index:
Ingres documentation excerpt on iiindexes catalog :
U if user object
G if generated by the system for the user
Blank if unknown
Used by utilities to determine which tables need reloading
Internal issue II-14927
Code change
The SQL statement used in
IngresDialect::get_indexes
is modified to also filter on thesystem_use
column and retrieve only user defined indexes (ignoring system generated indexes).Testing - SQLALchemy Dialect Compliance Suite
Command
pytest --db ingres_odbc -vv --maxfail=10000 .\test\dialect\test_suite.py --tb=no
(test.cfg contents:
ingres_odbc=ingres:///sqatestdb
)Results - DBMS: Ingres 12.0
Test results with DBMS targets: Vector 6.3 and Data Platform warehouse 620.0.18 (GCS)
This code change has NO impact when the backend is Vector or Data Platform, since the 84 tests of the dialect compliance suite under area ComponentReflectionTest::get_multi_indexes all involve DDL that tries to create a table with a self-referential constraint, which is not allowed on X100 tables.
When attempting to run the get_multi_indexes tests against an X100 backend, each of the tests fail with this error:
Environment