[Zope] *** Z SQL Method and type LONG ***

Jim Penny jpenny@universal-fasteners.com
Mon, 25 Nov 2002 14:30:24 -0500


On Mon, Nov 25, 2002 at 08:39:34PM +0200, Bo M. Maryniuck wrote:
> Hi.
> 
> Well, I have great surpri... no, rather trouble. Maybe I've something missed 
> (though I'm sure I'm not :), but how to pass to the SQL Method *long* type? 
> E.g. I need to pass to a DB a 999999999999999999999 as long, not as string 
> and SQL Method always fails, because /lib/python/Shared/DC/ZRDB/sqltest.py 
> can understand only "float", "string", "int" and "not blank". If you pass 
> type="int" this, for sure, runs int(value) and, sure, crashes. Should I use 
> _float_??? No! Once I've changed sqltest.py for "int" type make as long 
> (always). And it's work, but I would not like use my own patches for Zope...
> 
> So how to solve this in normal way?

pass as string and then do an explicit typecast.  E.g.  
(notation is postgresql):

<dtml-var my_big_int sql_quote>::int8

Notes:

You must not use sqlvar ... type=string, as that would create extra
quotes, that you do not want.

You do want to sql_quote the string to avoid SQL injection problems.

Jim Penny

> 
> -- 
> Regards, Bogdan
> 
> 1 4m 5o 3l337! just got r00t on this <a href="127.0.0.1">k3wl site</a> j00
> sux0r5!
> 
> 
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )
>