MCPcopy
hub / github.com/django/django / is_nullable

Method is_nullable

django/db/models/sql/query.py:2775–2791  ·  view source on GitHub ↗

Check if the given field should be treated as nullable. Some backends treat '' as null and Django treats such fields as nullable for those backends. In such situations field.null can be False even if we should treat the field as nullable.

(self, field)

Source from the content-addressed store, hash-verified

2773 return trimmed_prefix, contains_louter
2774
2775 def is_nullable(self, field):
2776 """
2777 Check if the given field should be treated as nullable.
2778
2779 Some backends treat '' as null and Django treats such fields as
2780 nullable for those backends. In such situations field.null can be
2781 False even if we should treat the field as nullable.
2782 """
2783 # We need to use DEFAULT_DB_ALIAS here, as QuerySet does not have
2784 # (nor should it have) knowledge of which connection is going to be
2785 # used. The proper fix would be to defer all decisions where
2786 # is_nullable() is needed to the compiler stage, but that is not easy
2787 # to do currently.
2788 return field.null or (
2789 field.empty_strings_allowed
2790 and connections[DEFAULT_DB_ALIAS].features.interprets_empty_strings_as_nulls
2791 )
2792
2793
2794def get_order_dir(field, default="ASC"):

Callers 2

build_filterMethod · 0.95
setup_joinsMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected