﻿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
22936	Get rid of field.get_db_prep_lookup()	Anssi Kääriäinen	nobody	"The field.get_db_prep_lookup() method is used to do preparation of a plain Python value for given lookup. Looking at the coding of [https://github.com/django/django/blob/master/django/db/models/fields/__init__.py#L655 get_db_prep_lookup()] the get_db_prep_lookup() is doing work that belongs into the lookup itself.

The same goes also for get_prep_lookup(). It seems that get_prep_lookup() is either doing something that should actually be done in get_prep_value(), or something that belongs into lookups.

If a custom field needs to do different kind of preparation for some lookups (something that can't be done in get_[db_]prep_value(), it can always provide a lookup subclass that does the right thing for that field type. An example is [https://github.com/django/django/blob/master/django/db/models/fields/__init__.py#L1717 IntegerField and 'lt' and 'gte' lookups]. Providing custom subclasses might be laborious to do if there are a lot of different lookup types that need custom preparation. For that reason a hook for custom fields could still be useful.

Even if we want to leave get_db_prep_lookup and get_prep_lookup hooks for custom fields, the base coding belongs into the lookups themselves. Currently the fields are doing work that clearly belongs to the lookup itself."	Cleanup/optimization	new	Database layer (models, ORM)	dev	Normal				Accepted	0	0	0	0	0	0
