Expand out the doco around auto coercion and validation
As per https://github.com/kvesteri/sqlalchemy-utils/issues/216
This commit is contained in:

committed by
Konsta Vesterinen

parent
64933dbfa3
commit
2a76d85669
@@ -65,6 +65,14 @@ def force_auto_coercion(mapper=None):
|
|||||||
document.background_color # Color object
|
document.background_color # Color object
|
||||||
session.commit()
|
session.commit()
|
||||||
|
|
||||||
|
A useful side-effect of this is that additional validation of data will be
|
||||||
|
done on the moment it is being assigned to model objects. For example
|
||||||
|
without auto coerction set, an invalid
|
||||||
|
:class:`sqlalchemy_utils.types.IPAddressType` (eg. ``10.0.0 255.255``)
|
||||||
|
would get through without an exception being raised. The database wouldn't
|
||||||
|
notice this (as most databases don't have a native type for an IP address,
|
||||||
|
so they're usually just stored as a string), and the ``ipaddress/ipaddr``
|
||||||
|
package uses a string field as well.
|
||||||
|
|
||||||
:param mapper: The mapper which the automatic data type coercion should be
|
:param mapper: The mapper which the automatic data type coercion should be
|
||||||
applied to
|
applied to
|
||||||
|
Reference in New Issue
Block a user