Closed
Description
Environment details
- Programming language: Python
- OS: debian (can be reproduce on any OS)
- Language runtime version: Python 3.11.7
- Package version: sqlalchemy-spanner==1.7.0, SQLAlchemy==1.4.49
Steps to reproduce
- Install Packages:
pip install SQLAlchemy==1.4.49 sqlalchemy-spanner==1.7.0
- Setup Engine:
from sqlalchemy import create_engine
# Replace the following with your actual database connection string
DATABASE_URL = "spanner+spanner:///projects/YOUR_PROJECT_ID/instances/YOUR_INSTANCE_ID/databases/YOUR_DATABASE_ID"
engine = create_engine(DATABASE_URL)
- Setup Database:
# SQL for creating the table
create_table_sql = """
CREATE TABLE clicks (
id INT64 NOT NULL,
date DATE NOT NULL,
url_hash STRING(32) NOT NULL,
url STRING(MAX) NOT NULL,
) PRIMARY KEY(id, date DESC, url_hash);
"""
# SQL for creating the index
create_index_sql = """
CREATE INDEX idx_on_clicks ON clicks(id, date DESC, url_hash) STORING (url);
"""
# Execute the SQL commands
with engine.connect() as connection:
connection.execute(create_table_sql)
connection.execute(create_index_sql)
- Reflect Database:
from sqlalchemy import MetaData, inspect
inspector = inspect(engine)
meta = MetaData(bind=engine)
MetaData.reflect(meta, views=True)
- Exception from Step 4:
File "/usr/local/lib/python3.11/site-packages/sqlalchemy/sql/schema.py", line 614, in __new__
table._init(name, metadata, *args, **kw)
File "/usr/local/lib/python3.11/site-packages/sqlalchemy/sql/schema.py", line 689, in _init
self._autoload(
File "/usr/local/lib/python3.11/site-packages/sqlalchemy/sql/schema.py", line 724, in _autoload
conn_insp.reflect_table(
File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/reflection.py", line 807, in reflect_table
self._reflect_indexes(
File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/reflection.py", line 1071, in _reflect_indexes
if k in c_sorting:
^^^^^^^^^^^^^^
TypeError: argument of type 'NoneType' is not iterable
Note: SQLAlchemy-2.0.30 also has the same issue.
Metadata
Metadata
Assignees
Labels
Issues related to the googleapis/python-spanner-sqlalchemy API.Issues related to the googleapis/python-spanner-sqlalchemy API.Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.