Skip to content
This repository has been archived by the owner on Sep 7, 2024. It is now read-only.

Empty array issue #10

Closed
franklx opened this issue Nov 3, 2011 · 2 comments
Closed

Empty array issue #10

franklx opened this issue Nov 3, 2011 · 2 comments

Comments

@franklx
Copy link

franklx commented Nov 3, 2011

SELECTing an array field (with any primitive type into) raises an exception:

[03/Nov/2011:21:17:23] HTTP Traceback (most recent call last):
  ...
  File "pg8000/types.py", line 442, in array_recv
    element_len, = struct.unpack("!i", data[:4])
error: unpack str size too short for format

This is caused by the "data" variabile containing an empty string.

A quick but working fix could be the following:

         if len(data):
             element_len, = struct.unpack("!i", data[:4])
         else:
             element_len = -1
@reingart
Copy link
Collaborator

I've made a googlecode fork and patched the source with your fix, could you test it?

http://code.google.com/p/pg8000/

http://code.google.com/p/pg8000/source/detail?r=c013f3f45c90bb4919fb388699a6d31bbbf864b1

tlocke referenced this issue in tlocke/pg8000 Jul 1, 2013
This fixes bug #10. Also added a test.

Tidied up code using pyflakes and pep8.
tlocke referenced this issue in tlocke/pg8000 Jul 1, 2013
Fixed the empty array bug.

Tidied up code with pyflakes and pep8.
tlocke added a commit that referenced this issue Jul 1, 2013
This fixes bug #10. Also added a test.

Tidied up code using pyflakes and pep8.
@tlocke
Copy link
Collaborator

tlocke commented Jul 1, 2013

I've fixed this in the Python 2 and 3 branches.

@tlocke tlocke closed this as completed Jul 1, 2013
reingart added a commit to reingart/pg8000 that referenced this issue Mar 3, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants