So I got the SybaseDA working, but now I notice that my REC_ID's (these are autoincrementing numeric columns in my tables) seem to always show as their number and an L. So like REC_ID 10 would be 10L to the zope DA. In ISQL they come out fine. What's the deal? -- Let us never negotiate out of fear, but let us never fear to negotiate. -- John F. Kennedy
Hi, In Python, a number followed by an 'L' is a Python long (which can be any integer, of arbitrary length). The SybaseDA figures out what type to return for numeric based on the length of the numeric - any numeric with no precision after the decimal point which might be too big to fit in a regular 32 bit integer is stuffed into a Python long. This works fine for most things, actually, except you have to cut off the end when you display the number as a string, and when you want to put things back in the DB, you have to somehow convert the value back into something that looks proper to SQL. I have a patch to sqlvar.py (in the lib/python/Shared/DC/ZRDB directory of your Zope installation) that adds long support to the sqlvar tag, so that you can write: <dtml-sqlvar REC_ID type=long> and Zope will cut the L off for you. This patch has been submitted to the Collector, but if you need it earlier I will put it on my Zope home page: http://www.zope.org/Members/brianh Hope this clears things up, Brian Hooper On Fri, 25 Feb 2000 22:24:02 -0700 jiva@devware.com wrote:
So I got the SybaseDA working, but now I notice that my REC_ID's (these are autoincrementing numeric columns in my tables) seem to always show as their number and an L. So like REC_ID 10 would be 10L to the zope DA. In ISQL they come out fine. What's the deal?
-- Let us never negotiate out of fear, but let us never fear to negotiate. -- John F. Kennedy
_______________________________________________ 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 )
Thanks for the great replies. I finally worked around it by doing a convert(int, fieldname) as field this will probably due for now, I don't expect to overflow an int for a while yet. This was still very useful to know tho... thanks! On Sat, Feb 26, 2000 at 02:20:08PM +0900, Brian Takashi Hooper wrote:
Hi,
In Python, a number followed by an 'L' is a Python long (which can be any integer, of arbitrary length).
The SybaseDA figures out what type to return for numeric based on the length of the numeric - any numeric with no precision after the decimal point which might be too big to fit in a regular 32 bit integer is stuffed into a Python long.
This works fine for most things, actually, except you have to cut off the end when you display the number as a string, and when you want to put things back in the DB, you have to somehow convert the value back into something that looks proper to SQL. I have a patch to sqlvar.py (in the lib/python/Shared/DC/ZRDB directory of your Zope installation) that adds long support to the sqlvar tag, so that you can write:
<dtml-sqlvar REC_ID type=long>
and Zope will cut the L off for you. This patch has been submitted to the Collector, but if you need it earlier I will put it on my Zope home page:
http://www.zope.org/Members/brianh
Hope this clears things up, Brian Hooper
On Fri, 25 Feb 2000 22:24:02 -0700 jiva@devware.com wrote:
So I got the SybaseDA working, but now I notice that my REC_ID's (these are autoincrementing numeric columns in my tables) seem to always show as their number and an L. So like REC_ID 10 would be 10L to the zope DA. In ISQL they come out fine. What's the deal?
_______________________________________________ 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 )
-- "Out of register space (ugh)" -- vi
On Fri, Feb 25, 2000 at 10:24:02PM -0700, jiva@devware.com wrote:
So I got the SybaseDA working, but now I notice that my REC_ID's (these are autoincrementing numeric columns in my tables) seem to always show as their number and an L. So like REC_ID 10 would be 10L to the zope DA. In ISQL they come out fine. What's the deal?
Python has normal integers (which are between -2^32+1 and 2^32-1) and long integers (which can be any size, bounded only by available memory). Without being familiar with Sybase, I would guess that REC_IDs could get larger than 31 bits in size, so Zope converts them to longs to prevent overflows in assigning to Python integers. When you print out a long in Python, it has an 'L' as the suffix to indicate that. It is sometimes important to realise a number is a long because if you are comparing types, 2L is not the same as 2 (it has the same value, but one is a long int, the other is an int). Cheers, Malcolm -- Malcolm Tredinnick ph: +61 2 9440 9885 CommSecure Pty Ltd mobile: 0409 663 876 email: malcolm@commsecure.com.au
participants (3)
-
Brian Takashi Hooper -
jiva@devware.com -
Malcolm Tredinnick