Skip to content

Commit 9e338c6

Browse files
committed
fix db insert issue for decimal fields on older sql compiler, #43
1 parent 3606ad3 commit 9e338c6

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

django_enum/fields.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ def get_prep_value(self, value: Any) -> Any:
465465
raise
466466
return value
467467

468-
def get_db_prep_value(self, value, connection, prepared=False):
468+
def get_db_prep_value(self, value, connection, prepared=False) -> Any:
469469
"""
470470
Convert the field value into the Enum type and then pull its value
471471
out.
@@ -476,6 +476,17 @@ def get_db_prep_value(self, value, connection, prepared=False):
476476
return self.get_prep_value(value)
477477
return value
478478

479+
def get_db_prep_save(self, value, connection) -> Any:
480+
"""
481+
For Django <= 3.2 the super class implementation of this method invokes
482+
a higher get_db_preb_value method.
483+
"""
484+
return self.get_db_prep_value(
485+
value,
486+
connection=connection,
487+
prepared=False
488+
)
489+
479490
def from_db_value(
480491
self,
481492
value: Any,

0 commit comments

Comments
 (0)