[CONPY-134] Using column named 'Element' causing unknown MySQL error Created: 2020-11-29  Updated: 2020-11-29  Resolved: 2020-11-29

Status: Closed
Project: MariaDB Connector/Python
Component/s: DBAPI 2.0
Affects Version/s: 1.0.4
Fix Version/s: N/A

Type: New Feature Priority: Minor
Reporter: V H Lemoine Assignee: Georg Richter
Resolution: Not a Bug Votes: 0
Labels: None
Environment:

Ubuntu 18.04, Mariadb 10.5.8



 Description   

used Table def:

CREATE TABLE `data` (
`Element` varchar(12) NOT NULL,
`Data` varchar(48) NOT NULL,
`Status` tinyint(1) unsigned DEFAULT 1,
`EmailAddress` varchar(96) DEFAULT NULL,
`Destination` varchar(12) DEFAULT NULL,
KEY `Element` (`Element`,`Data`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

cnx = mariadb.connect(**dbconfig)
cnx.autocommit = True
csr = cnx.cursor(dictionary=True, buffered=True)

csr.execute("select * from `data` where `Status`=1") is ok

csr.execute("select `Element`,`Data`,`EmailAddress`,`Destination` from `data` where `Status`=1") causes unknown MySQL error

csr.execute("select `Data`,`EmailAddress`,`Destination` from `data` where `Status`=1") is ok

So it seems that select `Element` .... causes the error.

When using select * from .... the column `Element` is returned correctly.



 Comments   
Comment by Georg Richter [ 2020-11-29 ]

I'm not able to reproduce it with latest GA (1.0.5)

import mariadb 
 
cnx = mariadb.connect(db="test")
csr = cnx.cursor(dictionary=True, buffered=True)
cnx.autocommit = True
csr.execute("CREATE TEMPORARY TABLE `data` ( `Element` varchar(12) NOT NULL, `Data` varchar(48) NOT NULL, `Status` tinyint(1) unsigned DEFAULT 1, `EmailAddress` varchar(96) DEFAULT NULL, `Destination` varchar(12) DEFAULT NULL, KEY `Element` (`Element`,`Data`)) ENGINE=InnoDB DEFAULT CHARSET=utf8")
csr.execute("select `Element`,`Data`,`EmailAddress`,`Destination` from `data` where `Status`=1") 
rows= csr.fetchall()
print(rows)
csr.execute('insert into data values ("foo", "bar", 1, "foo@bar.com", "TXL")')
csr.execute("select `Element`,`Data`,`EmailAddress`,`Destination` from `data` where `Status`=1") 
rows= csr.fetchall()
print(rows)

returns

[]
[{'Element': 'foo', 'Data': 'bar', 'EmailAddress': 'foo@bar.com', 'Destination': 'TXL'}]

Comment by V H Lemoine [ 2020-11-29 ]

The problem was caused by other factors, namely issuing 2 consecutive csr.execute statements without fetching records.

You may close this issue.

b.t.w. what are the changes in 1.0.5?

Comment by Georg Richter [ 2020-11-29 ]

closed on request.

For C/Python 1.0.5 changes please check 1.0.5 release notes

Generated at Thu Feb 08 03:30:30 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.