Details
-
Bug
-
Status: Closed (View Workflow)
-
Minor
-
Resolution: Not a Bug
-
1.1.6
-
None
-
Ubuntu linux 22.04
-
3.10.6
Description
This is table definition:
MariaDB [test]> show columns in mytable;
|
+---------------------+---------------+------+-----+---------+-------+
|
| Field | Type | Null | Key | Default | Extra |
|
+---------------------+---------------+------+-----+---------+-------+
|
| id | char(18) | NO | PRI | NULL | |
|
| active | tinyint(1) | YES | | 1 | |
|
| slots | int(11) | YES | | 100 | |
|
| differential | decimal(5,4) | YES | | 0.0100 | |
|
+---------------------+---------------+------+-----+---------+-------+
|
Running from the connector:
>>> dbc.execute(f'show columns in mytable')
|
>>> results = dbc.fetchall()
|
>>> print(results)
|
[{'Field': 'id', 'Type': 'char(18)', 'Null': 'NO', 'Key': 'PRI', 'Default': None, 'Extra': ''}, {'Field': 'active', 'Type': 'tinyint(1)', 'Null': 'YES', 'Key': '', 'Default': '1', 'Extra': ''}, {'Field': 'slots', 'Type': 'int(11)', 'Null': 'YES', 'Key': '', 'Default': '100', 'Extra': ''}, {'Field': 'differential', 'Type': 'decimal(5,4)', 'Null': 'YES', 'Key': '', 'Default': '0.0100', 'Extra': ''}]
|
Evidently all default values are returned as strings rather than the columns' respective types. The expected output should have been:
[{'Field': 'id', 'Type': 'char(18)', 'Null': 'NO', 'Key': 'PRI', 'Default': None, 'Extra': ''}, {'Field': 'active', 'Type': 'tinyint(1)', 'Null': 'YES', 'Key': '', 'Default': 1, 'Extra': ''}, {'Field': 'slots', 'Type': 'int(11)', 'Null': 'YES', 'Key': '', 'Default': 100, 'Extra': ''}, {'Field': 'differential', 'Type': 'decimal(5,4)', 'Null': 'YES', 'Key': '', 'Default': Decimal('0.0100'), 'Extra': ''}]
|