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

cursor(named_tuple=True) silently drops a column when two columns share a name

    XMLWordPrintable

Details

    Description

      A row can only carry a given field name once, so two columns with the same name ( like SELECT t1.id, t2.id FROM t1 JOIN t2 typically) can't both be reached. Both drivers accept it and lose a column silently:

      cur = conn.cursor(named_tuple=True)
      cur.execute("SELECT 1 AS id, 2 AS id")
      print(cur.fetchone())

      1. C extension: Row(id=1, id=2) -> row.id is 2, first column unreachable
      2. pure Python: Row(id=1, id_1=2) -> field name the query never asked for
        Once all columns are known, the result set should be rejected with a ProgrammingError naming the duplicate. Tuple and dictionary cursors are unaffected.

      Attachments

        Activity

          People

            diego dupin Diego Dupin
            diego dupin Diego Dupin
            Votes:
            0 Vote for this issue
            Watchers:
            1 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.