﻿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
8062	Re: #7560 casting now breaks filters (ints, bools, floats) in get_db_prep_value	magneto	nobody	"The Changes in r8131 in django/db/models/fields/__init__.py

to get_db_prep_value for the 'Casted' Field types (Auto, Int, Bool, Decimal, Dates, etc)  now really messes with the Filters

for instances, 'searching' where one wants to do a big 'Or' type statment

{{{

q = ""Some unknown String""
Obj.objects.filter(pk = q) | Obj.objects.filter(name = q) | Obj.objects.filter(other_field = q) 

}}}

this will now throw a Value Error in the ""pk = q""  if the ""q"" is not an Int ... yes, technically it should be an int, but when build complex queries, with many parameters, 'type checking' everything, in the supposed non-typed language does seem strange.

this, to me is bad form, (for one, 'AutoField' need not just be an Int, but a binary hash or some other unique thing) .. 

the data base (because the Query generator actually quotes the input argument) will certain not match non-ints,
i'd also imagine that 'bools' in some DBs can be '1/0, True/False, 'y/n', or just plain 'not 0'

Someone can correct me if i'm wrong, but i'm not sure of any DB today that will throw an error if one tries to match an int column to a string (id = ""abc""), so why is this forced type checking here as well?

I do agree that on a ""save"" event one wants to validate the types, but on a ""filter""?

"		closed	Database layer (models, ORM)	dev		wontfix		django@…	Design decision needed	0	0	0	0	0	0
