fix: Fix metadata reflection without a default dataset #1089
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Fixes #838 and fixes #1088. 🦕
The
get_table_names
andget_view_names
methods are supposed to return the bare names (no{schema}.
prefix) of the resources for a single schema/dataset (whereschema=None
is the "default schema", not "all schemas"). However, theBigQueryDialect
implementation returns:schema
: if the connection has a default dataset{schema}.
prefixed names for one schema: if the connection doesn't have a default dataset and theschema
arg is a string{schema}.
prefixed names for all schemas: if the connection doesn't have a default dataset and theschema
arg isNone
The bolded parts cause issues outlined in #1088. This PR fixes the
get_table_names
andget_view_names
implementations to return bare names as SQLAlchemy expects.This is a breaking change for a subset of users:
Metadata.reflect()
without aschema
argument were probably expecting to reflect all datasets, but they would now not reflect anything.public
) - so without a default set on the connection string, we don't have anything to search and return an empty list.This has been working for me locally with
alembic
+ no default dataset (the models specify the schema) +include_schemas=True
(required for cross-schema stuff).