Skip to content

Commit 75f5a34

Browse files
committed
BUG24955338: Fix Schema.get_tables() and Schema.get_collections() value error
The Schema.get_tables() and Schema.get_collections() raises a ValueError, using MySQL 5.7.14. This patch fixes this issue by adding the correct column name for recent MySQL versions and maintaining the support for the old ones. The current tests already detects this issue.
1 parent 6dc2ea9 commit 75f5a34

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/mysqlx/crud.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,10 @@ def get_collections(self):
142142
for row in rows:
143143
if row.get_string("type") != "COLLECTION":
144144
continue
145-
collection = Collection(self, row.get_string("name"))
145+
try:
146+
collection = Collection(self, row.get_string("TABLE_NAME"))
147+
except ValueError:
148+
collection = Collection(self, row.get_string("name"))
146149
collections.append(collection)
147150
return collections
148151

@@ -167,7 +170,10 @@ def get_tables(self):
167170
object_types = ("TABLE", "VIEW",)
168171
for row in rows:
169172
if row.get_string("type") in object_types:
170-
table = Table(self, row.get_string("name"))
173+
try:
174+
table = Table(self, row.get_string("TABLE_NAME"))
175+
except ValueError:
176+
table = Table(self, row.get_string("name"))
171177
tables.append(table)
172178
return tables
173179

0 commit comments

Comments
 (0)