Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Back to the original value_to_db_auto solution.

  • Loading branch information...
commit c68fd7ecc9882917d50c44e3bf1e07a8f183d7d5 1 parent 69ad031
Wojtek Ruszczewski authored March 21, 2012
9  django/db/backends/__init__.py
@@ -673,6 +673,15 @@ def prep_for_like_query(self, x):
673 673
     # need not necessarily be implemented using "LIKE" in the backend.
674 674
     prep_for_iexact_query = prep_for_like_query
675 675
 
  676
+    def value_to_db_auto(self, value):
  677
+        """
  678
+        Transform an AutoField value to an object compatible with what is expected
  679
+        by the backend driver for automatic keys.
  680
+        """
  681
+        if value is None:
  682
+            return None
  683
+        return int(value)
  684
+
676 685
     def value_to_db_date(self, value):
677 686
         """
678 687
         Transform a date value to an object compatible with what is expected
4  django/db/models/fields/__init__.py
@@ -463,9 +463,7 @@ def validate(self, value, model_instance):
463 463
         pass
464 464
 
465 465
     def get_db_prep_value(self, value, connection, prepared=False):
466  
-        if value is None:
467  
-            return value
468  
-        return connection.settings_dict.get('AUTOFIELD_TYPE', int)(value)
  466
+        return connection.ops.value_to_db_auto(value)
469 467
 
470 468
     def contribute_to_class(self, cls, name):
471 469
         assert not cls._meta.has_auto_field, "A model can't have more than one AutoField."

0 notes on commit c68fd7e

Please sign in to comment.
Something went wrong with that request. Please try again.