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

Fix get_multi_columns() to support multiple table names #221

Merged
merged 2 commits into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Unreleased

- Implement reflection for array types (#213)
- Fix get_multi_columns() to support multiple table names in filter_array (#220)

# Version 2.0.1
April 14, 2023
Expand Down
28 changes: 17 additions & 11 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ certifi==2023.7.22
# via requests
cffi==1.15.1
# via cryptography
charset-normalizer==3.1.0
charset-normalizer==3.2.0
# via requests
cryptography==41.0.3
# via secretstorage
distlib==0.3.6
distlib==0.3.7
# via virtualenv
docutils==0.20.1
# via readme-renderer
Expand All @@ -18,11 +18,13 @@ filelock==3.12.2
# virtualenv
idna==3.4
# via requests
importlib-metadata==6.7.0
importlib-metadata==6.8.0
# via
# keyring
# twine
jaraco-classes==3.2.3
importlib-resources==6.0.0
# via keyring
jaraco-classes==3.3.0
# via keyring
jeepney==0.8.0
# via
Expand All @@ -34,13 +36,13 @@ markdown-it-py==3.0.0
# via rich
mdurl==0.1.2
# via markdown-it-py
more-itertools==9.1.0
more-itertools==10.0.0
# via jaraco-classes
packaging==23.1
# via tox
pkginfo==1.9.6
# via twine
platformdirs==3.8.0
platformdirs==3.10.0
# via virtualenv
pluggy==1.2.0
# via tox
Expand All @@ -62,7 +64,7 @@ requests-toolbelt==1.0.0
# via twine
rfc3986==2.0.0
# via twine
rich==13.4.2
rich==13.5.1
# via twine
secretstorage==3.3.3
# via keyring
Expand All @@ -76,13 +78,17 @@ tox==3.23.1
# via -r dev-requirements.in
twine==4.0.2
# via -r dev-requirements.in
urllib3==2.0.3
typing-extensions==4.7.1
# via rich
urllib3==2.0.4
# via
# requests
# twine
virtualenv==20.23.1
virtualenv==20.24.2
# via tox
webencodings==0.5.1
# via bleach
zipp==3.15.0
# via importlib-metadata
zipp==3.16.2
# via
# importlib-metadata
# importlib-resources
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
addopts = "--tb native -v -r sfxX --maxfail=250 -p warnings -p logging --strict-markers"
markers = [
"backend: tests that should run on all backends; typically dialect-sensitive",
"mypy: mypy integration / plugin tests",
]
21 changes: 7 additions & 14 deletions sqlalchemy_cockroachdb/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,20 +160,13 @@ def has_table(self, conn, table, schema=None, info_cache=None):
# Upstream implementation needs pg_table_is_visible().
return any(t == table for t in self.get_table_names(conn, schema=schema))

def get_multi_columns(
self, connection, schema, filter_names, scope, kind, **kw
):
"""
PGDialect in SQLA 2.0 uses get_multi_columns() when reflecting a table
using Table(…, autoload_with=engine), so we'll just return the values
for the first table in the filter_names list for now (since there
should only be just one).
"""
if not filter_names or not isinstance(filter_names, list) or len(filter_names) > 1:
raise ValueError("filter_names must be a single-value list (for now)")
table_name = filter_names[0]
col_info = self.get_columns(connection, table_name, schema, **kw)
return {(schema, table_name): col_info}
def get_multi_columns(self, connection, schema, filter_names, scope, kind, **kw):
if not filter_names:
filter_names = self.get_table_names(connection, schema)
return {
(schema, table_name): self.get_columns(connection, table_name, schema, **kw)
for table_name in filter_names
}

# The upstream implementations of the reflection functions below depend on
# correlated subqueries which are not yet supported.
Expand Down
18 changes: 9 additions & 9 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
alembic==1.11.1
alembic
# via -r test-requirements.in
asyncpg==0.27.0
asyncpg==0.28.0
# via -r test-requirements.in
attrs==23.1.0
# via pytest
futures==3.0.5
# via -r test-requirements.in
greenlet==2.0.2
# via sqlalchemy
importlib-metadata==6.7.0
importlib-metadata==6.8.0
# via alembic
importlib-resources==5.12.0
importlib-resources==6.0.0
# via alembic
iniconfig==2.0.0
# via pytest
mako==1.2.4
# via alembic
markupsafe==2.1.3
# via mako
mock==5.0.2
mock==5.1.0
# via -r test-requirements.in
more-itertools==9.1.0
more-itertools==10.0.0
# via -r test-requirements.in
packaging==23.1
# via pytest
Expand All @@ -32,17 +32,17 @@ py==1.11.0
# via pytest
pytest==7.1.3
# via -r test-requirements.in
sqlalchemy==2.0.17
sqlalchemy
# via
# -r test-requirements.in
# alembic
tomli==2.0.1
# via pytest
typing-extensions==4.6.3
typing-extensions==4.7.1
# via
# alembic
# sqlalchemy
zipp==3.15.0
zipp==3.16.2
# via
# importlib-metadata
# importlib-resources
Loading