- Fixed bug in delete-orphan cascade whereby two one-to-one
relations from two different parent classes to the same target
class would prematurely expunge the instance.
-
+
- sql
- Further fixes to the "percent signs and spaces in column/table
names" functionality. [ticket:1284]
- Restored convert_unicode handling. Results were being passed
on through without conversion. [ticket:1291]
+ - Really fixing the decimal handling this time. [ticket:1282].
+
0.5.1
========
if value is None:
# Not sure that this exception is needed
return value
- else:
- if isinstance(value, decimal.Decimal):
- sign = (value < 0 and '-' or '')
- if value._exp > -1:
- return float(sign + value._int + '0' * value._exp)
- else:
- s = value._int.zfill(-value._exp+1)
- pos = len(s) + value._exp
- return sign + s[:pos] + '.' + s[pos:]
+
+ elif isinstance(value, decimal.Decimal):
+ if value.adjusted() < 0:
+ result = "%s0.%s%s" % (
+ (value < 0 and '-' or ''),
+ '0' * (abs(value.adjusted()) - 1),
+ "".join([str(nint) for nint in value._int]))
+
else:
- return value
+ if 'E' in str(value):
+ result = "%s%s%s" % (
+ (value < 0 and '-' or ''),
+ "".join([str(s) for s in value._int]),
+ "0" * (value.adjusted() - (len(value._int)-1)))
+ else:
+ if (len(value._int) - 1) > value.adjusted():
+ result = "%s%s.%s" % (
+ (value < 0 and '-' or ''),
+ "".join([str(s) for s in value._int][0:value.adjusted() + 1]),
+ "".join([str(s) for s in value._int][value.adjusted() + 1:]))
+ else:
+ result = "%s%s" % (
+ (value < 0 and '-' or ''),
+ "".join([str(s) for s in value._int][0:value.adjusted() + 1]))
+
+ return result
+
+ else:
+ return value
return process
try:
test_items = [decimal.Decimal(d) for d in '1500000.00000000000000000000',
'-1500000.00000000000000000000', '1500000',
- '0.0000000000000000002', '0.2', '-0.0000000000000000002',
- '156666.458923543', '-156666.458923543', '1', '-1', '1234',
+ '0.0000000000000000002', '0.2', '-0.0000000000000000002', '-2E-2',
+ '156666.458923543', '-156666.458923543', '1', '-1', '-1234', '1234',
'2E-12', '4E8', '3E-6', '3E-7', '4.1', '1E-1', '1E-2', '1E-3',
- '1E-4', '1E-5', '1E-6', '1E-7', '1E-8']
+ '1E-4', '1E-5', '1E-6', '1E-7', '1E-1', '1E-8', '0.2732E2', '-0.2432E2', '4.35656E2',
+ '-02452E-2', '45125E-2',
+ '1234.58965E-2', '1.521E+15', '-1E-25', '1E-25', '1254E-25', '-1203E-25',
+ '0', '-0.00', '-0', '4585E12', '000000000000000000012', '000000000000.32E12',
+ '00000000000000.1E+12', '000000000000.2E-32']
+
for value in test_items:
numeric_table.insert().execute(numericcol=value)