Issue Details (XML | Word | Printable)

Key: PYFB-25
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Pavel Cisar
Reporter: nepomnyashiy evgeniy
Votes: 0
Watchers: 1

If you were logged in you would be able to see more operations.
Firebird driver for Python

Trancate long text from VARCHAR(5000)

Created: 26/Jan/13 09:15 PM   Updated: 07/Mar/13 01:56 PM
Component/s: None
Affects Version/s: 0.9.9
Fix Version/s: 1.0

Environment: firebird 2.5 64 bits, windows 2003R2, python 27

 Description  « Hide
I have table with field
    "field" "Text" /* "Text" = VARCHAR(5000) */,

One record have text of about 2500 chars in this field.
If I select this record, I receive only 213 chars.

cur = con.cursor()
cur.execute('SELECT "field" from "table" where id=?', [id])
for m in cur.itermap():
  print m["field"]

With kinterbasdb this works fine

 All   Comments   Change History   Subversion Commits      Sort Order: Descending order - Click to sort in ascending order
Slava added a comment - 27/Feb/13 06:52 PM
I also ran into this problem. Today I played with driver code and wrote small fix, exactly like your evgeniy.

nepomnyashiy evgeniy added a comment - 28/Jan/13 11:13 AM
see fbcore, line 2075

elif vartype == SQL_VARYING:
                size = bytes_to_uint(sqlvar.sqldata[:1]) # ******************************
                #value = ctypes.string_at(sqlvar.sqldata[2],2+size)
                ### Todo: verify handling of P version differences
                if PYTHON_MAJOR_VER == 3:
                    value = bytes(sqlvar.sqldata[2:2 + size])
                    value = str(sqlvar.sqldata[2:2 + size])
                if ((self.__charset or PYTHON_MAJOR_VER == 3)
                    and sqlvar.sqlsubtype != 1): # non OCTETS
                    value = b2u(value,self.__python_charset)

replace selected string with
size = bytes_to_uint(sqlvar.sqldata[:2])