Uploaded image for project: 'MariaDB Connector/Python'
  1. MariaDB Connector/Python
  2. CONPY-264

Incorrect types for defaults returned for `show columns in table`

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Minor
    • Resolution: Not a Bug
    • 1.1.6
    • N/A
    • Parser
    • 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': ''}]
      

      Attachments

        Activity

          People

            georg Georg Richter
            Prsa Andrej
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.