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

CHAR column returns inconsistent Python types

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Minor
    • Resolution: Fixed
    • 1.0.5
    • 1.0.6
    • DBAPI 2.0
    • None
    • 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

            georg Georg Richter
            LeeClemens Lee Clemens
            Votes:
            0 Vote for this issue
            Watchers:
            2 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.