mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Fixed queries that may return unexpected results on MySQL due to typecasting.
This is a security fix; disclosure to follow shortly.
This commit is contained in:
@@ -66,6 +66,16 @@ options that make it very powerful.
|
||||
database, but does nothing to enforce that. If the query does not
|
||||
return rows, a (possibly cryptic) error will result.
|
||||
|
||||
.. warning::
|
||||
|
||||
If you are performing queries on MySQL, note that MySQL's silent type coercion
|
||||
may cause unexpected results when mixing types. If you query on a string
|
||||
type column, but with an integer value, MySQL will coerce the types of all values
|
||||
in the table to an integer before performing the comparison. For example, if your
|
||||
table contains the values ``'abc'``, ``'def'`` and you query for ``WHERE mycolumn=0``,
|
||||
both rows will match. To prevent this, perform the correct typecasting
|
||||
before using the value in a query.
|
||||
|
||||
Mapping query fields to model fields
|
||||
------------------------------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user