Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trancate long text from VARCHAR(5000) [PYFB25] #48

Closed
firebird-automations opened this issue Jan 26, 2013 · 5 comments
Closed

Trancate long text from VARCHAR(5000) [PYFB25] #48

firebird-automations opened this issue Jan 26, 2013 · 5 comments

Comments

@firebird-automations
Copy link

Submitted by: nepomnyashiy evgeniy (nepomnyashiy evgeniy)

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

Commits: 3354699

@firebird-automations
Copy link
Author

Modified by: nepomnyashiy evgeniy (nepomnyashiy evgeniy)

description: I have table with field
{code}
"field" "Text" /* "Text" = VARCHAR(5000) */,
{code}

One record have text of about 2500 chars in this field.
If I select this record, I receive only 213 chars.
{code}
cur = con.cursor()
cur.execute('SELECT "field" from "table" where id=?', [id])
for m in cur.itermap():
print m["field"]
{code}

With kinterbasdb this works fine

=>

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

@firebird-automations
Copy link
Author

Commented by: nepomnyashiy evgeniy (nepomnyashiy evgeniy)

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])
else:
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])

@firebird-automations
Copy link
Author

Commented by: Slava (slava)

I also ran into this problem. Today I played with driver code and wrote small fix, exactly like your evgeniy.

@firebird-automations
Copy link
Author

Modified by: @pcisar

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

Fix Version: 1.0 [ 10500 ]

@firebird-automations
Copy link
Author

Modified by: @pcisar

status: Resolved [ 5 ] => Closed [ 6 ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants