Commit 736e001
committed
fix(sqlalchemy-spanner): add TOKENLIST type and unknown type fallback in introspection
Spanner full-text search uses TOKENLIST columns, but the dialect does
not recognize this type — _type_map has no entry and _designate_type()
crashes with KeyError on any unrecognized type string.
This change:
1. Adds a first-class TOKENLIST type (TypeEngine subclass) with
forward mapping (_type_map), inverse mapping (_type_map_inv), and
DDL compilation (SpannerTypeCompiler.visit_TOKENLIST). This ensures
schema introspection roundtrips correctly through Alembic and
other DDL tools, and allows TOKENLIST columns to be referenced
in SEARCH()/SCORE()/SNIPPET() queries via SQLAlchemy.
2. Adds a fallback in _designate_type() so unrecognized types return
NullType with a warning instead of crashing. This future-proofs
against new Spanner types.
The Go client had the same gap and fixed it in
googleapis/google-cloud-go#11522 (released in spanner v1.78.0),
which added TOKENLIST as a first-class TypeBase.
Fixes #166211 parent c3bd6c0 commit 736e001
File tree
2 files changed
+111
-1
lines changed- packages/sqlalchemy-spanner
- google/cloud/sqlalchemy_spanner
- tests/unit
2 files changed
+111
-1
lines changedLines changed: 29 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
107 | 108 | | |
108 | 109 | | |
109 | 110 | | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
110 | 126 | | |
111 | 127 | | |
112 | 128 | | |
| |||
122 | 138 | | |
123 | 139 | | |
124 | 140 | | |
| 141 | + | |
125 | 142 | | |
126 | 143 | | |
127 | 144 | | |
| |||
140 | 157 | | |
141 | 158 | | |
142 | 159 | | |
| 160 | + | |
143 | 161 | | |
144 | 162 | | |
145 | 163 | | |
| |||
819 | 837 | | |
820 | 838 | | |
821 | 839 | | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
822 | 843 | | |
823 | 844 | | |
824 | 845 | | |
| |||
1226 | 1247 | | |
1227 | 1248 | | |
1228 | 1249 | | |
1229 | | - | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
1230 | 1258 | | |
1231 | 1259 | | |
1232 | 1260 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
0 commit comments