Ticket #10224: djangooraclebinary.diff
File djangooraclebinary.diff, 3.4 KB (added by aprilmay, 8 years ago) 


djangotrunk/django/db/backends/oracle/base.py
421 421 # cursor description, and convert strings to unicode. 422 422 casted = [] 423 423 for value, desc in zip(row, self.cursor.description): 424 if value is not None and desc[1] is Database.NUMBER: 425 precision, scale = desc[4:6] 426 if scale == 127: 427 if precision == 0: 428 # NUMBER column: decimalprecision floating point 429 # This will normally be an integer from a sequence, 430 # but it could be a decimal value. 431 if '.' in value: 432 value = Decimal(value) 424 if value is not None: 425 if desc[1] is Database.NUMBER: 426 precision, scale = desc[4:6] 427 if scale == 127: 428 if precision == 0: 429 # NUMBER column: decimalprecision floating point 430 # This will normally be an integer from a sequence, 431 # but it could be a decimal value. 432 if '.' in value: 433 value = Decimal(value) 434 else: 435 value = int(value) 433 436 else: 437 # FLOAT column: binaryprecision floating point. 438 # This comes from FloatField columns. 439 value = float(value) 440 elif precision > 0: 441 # NUMBER(p,s) column: decimalprecision fixed point. 442 # This comes from IntField and DecimalField columns. 443 if scale == 0: 434 444 value = int(value) 445 else: 446 value = Decimal(value) 447 elif '.' in value: 448 # No type information. This normally comes from a 449 # mathematical expression in the SELECT list. Guess int 450 # or Decimal based on whether it has a decimal point. 451 value = Decimal(value) 435 452 else: 436 # FLOAT column: binaryprecision floating point.437 # This comes from FloatField columns.438 value = float(value)439 elif precision > 0:440 # NUMBER(p,s) column: decimalprecision fixed point.441 # This comes from IntField and DecimalField columns.442 if scale == 0:443 453 value = int(value) 444 else:445 value = Decimal(value)446 elif '.' in value:447 # No type information. This normally comes from a448 # mathematical expression in the SELECT list. Guess int449 # or Decimal based on whether it has a decimal point.450 value = Decimal(value)451 else:452 value = int(value)453 454 else: 454 455 value = to_unicode(value) 455 456 casted.append(value)