Skip to content

Commit 71236bc

Browse files
committed
Use field column for getting converter
A field is also an expression, but the intention is that a column expression is passed. It seems to work fine with the field, but let's be safe and do the same thing Django does internally.
1 parent 56356ab commit 71236bc

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

psqlextra/query.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,13 +409,16 @@ def _create_model_instance(
409409

410410
# converters can be defined on the field, or by
411411
# the database back-end we're using
412+
field_column = field.get_col(self.model._meta.db_table)
412413
converters = field.get_db_converters(
413414
connection
414-
) + connection.ops.get_db_converters(field)
415+
) + connection.ops.get_db_converters(field_column)
415416

416417
for converter in converters:
417418
converted_field_values[field.attname] = converter(
418-
converted_field_values[field.attname], field, connection
419+
converted_field_values[field.attname],
420+
field_column,
421+
connection,
419422
)
420423

421424
instance = self.model(**converted_field_values)

0 commit comments

Comments
 (0)