What steps will reproduce the problem? 1. Create a table having a field of type 'string'. Use the field name 'telephone' as an example.
Insert a record having the field telephone=''.
Retrieve the record and the field named 'telephone' in the Row object has the None object as its value. What is the expected output? What do you see instead? A NULL field in the database is represented as the None object in Python. An empty string in a database field is represented as a zero-length string in Python (""). The two cases should be distinct. What version of the product are you using? On what operating system? Using 1.91.6 on FreeBSD 8.1. Please provide any additional information below. I noticed this problem after upgrading web2py to 1.91.6.
A local module for MySQL database support (gluon.contrib.pymysql) was introduced in 1.90.1 and seems to be the source of the problem.
After some debugging, I made changed the following function (in gluon/contrib/pymysql/connections.py) to correct the problem. Notice the 'if' statement.
def read_length_coded_binary(self):
"""Read a 'Length Coded Binary' from the data buffer.
A 'Length Coded Binary' consists first of a length coded
(unsigned, positive) integer represented in 1-9 bytes followed by
that many bytes of binary data. (For example "cat" would be "3cat".)
"""
length = self.read_coded_length()
if length is not None: # was 'if length:'
return self.read(length)
This resolves the problem that I am seeing. Whether it is the proper fix or not I will leave to your decision.
From Tech.Eds...@gmail.com on January 14, 2011 11:40:41
What steps will reproduce the problem? 1. Create a table having a field of type 'string'. Use the field name 'telephone' as an example.
A local module for MySQL database support (gluon.contrib.pymysql) was introduced in 1.90.1 and seems to be the source of the problem.
After some debugging, I made changed the following function (in gluon/contrib/pymysql/connections.py) to correct the problem. Notice the 'if' statement.
def read_length_coded_binary(self): """Read a 'Length Coded Binary' from the data buffer.
This resolves the problem that I am seeing. Whether it is the proper fix or not I will leave to your decision.
Original issue: http://code.google.com/p/web2py/issues/detail?id=157