[PyGreSQL] Patch to add read support for integer arrays

Mikko Korkalo mikko at korkalo.fi
Fri Mar 21 14:58:38 EDT 2008


Hi,

Here's a unified diff against the CVS version of pgdb.py (1.36).
I also optimized parsing of arrays by using substring instead of 
string.replace().

I also attached a bzipped version of the whole pgdb.py in case you have 
trouble with this patch.

I couldn't test this pgdb.py version properly, seems that it's partly 
incompatible with the rest of the python/postgresql/pygresql stuff I 
have on my Ubuntu 7.10 workstation. For example, booleans are broken for 
some reason.
Anyway I tested the integer array part, and it seemed to work.
I suggest that you test this before putting it into production.

-Mikko

D'Arcy J.M. Cain wrote:
> On Fri, 21 Mar 2008 15:56:12 +0200
> Mikko Korkalo <mikko at korkalo.fi> wrote:
>> I figured pgdb.py (version 1.33) didn't have support to read int2[] and 
>> int4[] types, so I added support for it. I don't know if this was in the 
>> CVS/SVN tree already.
>>
>> When reading data, int2[] and int4[] are now converted to a list 
>> containing ints, instead of passing them as str, i.e. '{ 1, 2 }' to the 
>> program.
> 
> That's nice.  Can you submit the patch as a context diff though?
> Sometimes the HEAD has changed enough so that the line numbers are only
> approximate.  Context diffs allow us to confirm the position.  Even
> clearer is unified diffs.  If you are using diff (or cvs diff) just add
> "-u" to get unified diffs.
> 
>> I don't know if this is the correct way to do this.
>> Maybe all of the array types should be handled at once?
> 
> There is some refactoring need in that area.  This might be a good time
> to look at that.
> 
>> --------
>> 109a110,114
>>  >               elif typ == INTARRAY:
>>  >                       tmp = value.replace("{", "").replace("}", 
>> "").split(",")
>>  >                       value=[]
>>  >                       for v in tmp:
>>  >                               value.append(int(v))
>> 413a419
>>  > INTARRAY = pgdbType('_int2', '_int4')
>> --------
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: pgdb.intarray2.patch
Type: text/x-patch
Size: 631 bytes
Desc: not available
Url : http://mailman.vex.net/pipermail/pygresql/attachments/20080321/d0462bcc/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pgdb.py.bz2
Type: application/x-bzip
Size: 4450 bytes
Desc: not available
Url : http://mailman.vex.net/pipermail/pygresql/attachments/20080321/d0462bcc/attachment-0001.bin 


More information about the PyGreSQL mailing list