﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
18031	Subclassing a model field: call_with_connection_and_prepared bug	smbrooks1@…	nobody	"A custom model Field class whose get_db_prep_value method calls super(..., self).get_db_prep_value(value, connection, prepared) sees an exception raised in django.db.models.fields.subclassing on line 53 in inner.
!TypeError: get_db_prep_value() got multiple values for keyword argument 'connection'.

It is happening because the 'inner' function of 'call_with_connection_and_prepared' looks for 'connection' in kwargs, and if not there, it adds it. However, in this case, it is present as a positional argument - hence the duplication.

NOTE: The 'call_with_connection' has a similar construction and most likely suffers from the same problem.

To reproduce:


{{{
from django.db import models

class MyField(models.CharField):
    def get_db_prep_value(self, value, connection, prepared=False):
        return super(MyField, self).get_db_prep_value(value, connection, prepared)
}}}
Then define a model using this field, create an instance and try to save it.

{{{
class MyModel(models.Model):
    myfield = MyField()

mm = MyModel()
mm.myfield = 'test'
mm.save()
}}}
If you enable DeprecationWarnings, you will see that the !DeprecationWarning issued on line 49 of subclassing, in the 'inner' function, is displayed."	Bug	closed	Database layer (models, ORM)	1.3	Normal	wontfix	Custom Field, get_db_prep_value		Unreviewed	0	0	0	0	0	0
