#2519: aligning sqlite3 with postgresql_psycopg2 adapter
-----------------------------------+----------------------------------------
Reporter: [EMAIL PROTECTED] | Owner: adrian
Type: enhancement | Status: new
Priority: normal | Milestone:
Component: Admin interface | Version:
Severity: normal | Resolution:
Keywords: |
-----------------------------------+----------------------------------------
Comment (by Victor Ng <[EMAIL PROTECTED]>):
Whoops. I forgot to include the diff to django.db.backends.util
This basically - along with the prior patch - will register a convert to
PySQLite to convert SQL numeric column types to decimal.Decimal if the
current running version of Python allows it. So we don't break
compatibility with Python 2.3, but if you *are* running Python 2.4+, you
get proper decimal handling.
{{{
Index: util.py
===================================================================
--- util.py (revision 3549)
+++ util.py (working copy)
@@ -41,7 +41,17 @@
###############################################
# Converters from database (string) to Python #
###############################################
+import sys
+version = float('.'.join(map(str, sys.version_info[:2])))
+if version >= 2.4:
+ from decimal import Decimal
+ def typecast_numeric(s):
+ return Decimal(s)
+else:
+ def typecast_numeric(s):
+ return float(s)
+
def typecast_date(s):
return s and datetime.date(*map(int, s.split('-'))) or None # returns
None if s is null
@@ -89,6 +99,9 @@
# Converters from Python to database (string) #
###############################################
+def rev_typecast_decimal(number):
+ return number.to_eng_string()
+
def rev_typecast_boolean(obj, d):
return obj and '1' or '0'
}}}
--
Ticket URL: <http://code.djangoproject.com/ticket/2519>
Django <http://code.djangoproject.org/>
The web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates
-~----------~----~----~----~------~----~------~--~---