Skip to content

Commit 527f180

Browse files
fix(sqlalchemy-spanner): register TOKENLIST in _type_map for reflection
Table reflection raises KeyError: 'TOKENLIST' whenever a table containing a TOKENLIST column is reflected. Fixes this issue by registering "TOKENLIST": types.String in _type_map in google/cloud/sqlalchemy_spanner/sqlalchemy_spanner.py.
1 parent 5b2da81 commit 527f180

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

packages/sqlalchemy-spanner/google/cloud/sqlalchemy_spanner/sqlalchemy_spanner.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ def process(value):
120120
"TIMESTAMP": types.TIMESTAMP,
121121
"ARRAY": types.ARRAY,
122122
"JSON": types.JSON,
123+
"TOKENLIST": types.String,
123124
}
124125

125126

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Copyright 2026 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from sqlalchemy import types
16+
from sqlalchemy.testing import eq_, fixtures
17+
from google.cloud.sqlalchemy_spanner.sqlalchemy_spanner import _type_map, SpannerDialect
18+
19+
20+
class TokenlistTest(fixtures.TestBase):
21+
def test_tokenlist_reflection_type_mapping(self):
22+
"""Test mockserver reflection mapping for TOKENLIST columns."""
23+
dialect = SpannerDialect()
24+
eq_(_type_map.get("TOKENLIST"), types.String)
25+
col_type = dialect._designate_type("TOKENLIST")
26+
eq_(col_type, types.String)

0 commit comments

Comments
 (0)