summaryrefslogtreecommitdiff
path: root/tests/custom_pk/fields.py
diff options
context:
space:
mode:
authorAdam Johnson <me@adamj.eu>2021-02-13 08:58:24 +0000
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2021-04-07 17:10:00 +0200
commitd9de74141e8a920940f1b91ed0a3ccb835b55729 (patch)
treeca551200e57591729cee1df19b7882adb36d3707 /tests/custom_pk/fields.py
parent619f26d2895d121854b1bed1b535d42b722e2eba (diff)
Fixed #32442 -- Used converters on returning fields from INSERT statements.
Diffstat (limited to 'tests/custom_pk/fields.py')
-rw-r--r--tests/custom_pk/fields.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/tests/custom_pk/fields.py b/tests/custom_pk/fields.py
index 5bd249df3c..bc7259300b 100644
--- a/tests/custom_pk/fields.py
+++ b/tests/custom_pk/fields.py
@@ -20,7 +20,7 @@ class MyWrapper:
return self.value == other
-class MyAutoField(models.CharField):
+class MyWrapperField(models.CharField):
def __init__(self, *args, **kwargs):
kwargs['max_length'] = 10
@@ -58,3 +58,15 @@ class MyAutoField(models.CharField):
if isinstance(value, MyWrapper):
return str(value)
return value
+
+
+class MyAutoField(models.BigAutoField):
+ def from_db_value(self, value, expression, connection):
+ if value is None:
+ return None
+ return MyWrapper(value)
+
+ def get_prep_value(self, value):
+ if value is None:
+ return None
+ return int(value)