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

CHAR column returns inconsistent Python types

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.0.5
    • Fix Version/s: 1.0.6
    • Component/s: DBAPI 2.0
    • Labels:
      None
    • Environment:
      CentOS 7
      MariaDB 10.5.8-MariaDB-log
      Python 3.9.1

      Description

      Hello,

      I noticed different types are returned when querying (at least) columns of VARCHAR and CHAR types depending upon prepared, but consistent for TEXT.

      When the query is executed (not prepared), the connector returns `str` which is expected from my reading of PEP 249.

      However, if `prepared=True` is used when creating the cursor, the returned values are of type `bytes` for VARCHAR and CHAR.

      I would expect the returned types to be consistent, regardless of being a prepared statement.

      https://gist.github.com/leeclemens/812027ba306363de61266135e31e30c9

      Produces:

        Testing BASE_QRY
        [<class 'str'>, <class 'str'>]
        [<class 'str'>, <class 'str'>]
        Testing WHERE_QRY
        [<class 'str'>, <class 'str'>]
        Testing PREPARED_QRY
        [<class 'bytes'>, <class 'str'>]
      

        Attachments

          Activity

            People

            Assignee:
            georg Georg Richter
            Reporter:
            LeeClemens Lee Clemens
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Git Integration