MCPcopy
hub / github.com/django/django / check

Method check

django/db/models/constraints.py:344–440  ·  view source on GitHub ↗
(self, model, connection)

Source from the content-addressed store, hash-verified

342 return bool(self.expressions)
343
344 def check(self, model, connection):
345 errors = model._check_local_fields({*self.fields, *self.include}, "constraints")
346 required_db_features = model._meta.required_db_features
347 if self.condition is not None and not (
348 connection.features.supports_partial_indexes
349 or "supports_partial_indexes" in required_db_features
350 ):
351 errors.append(
352 checks.Warning(
353 f"{connection.display_name} does not support unique constraints "
354 "with conditions.",
355 hint=(
356 "A constraint won't be created. Silence this warning if you "
357 "don't care about it."
358 ),
359 obj=model,
360 id="models.W036",
361 )
362 )
363 if self.deferrable is not None and not (
364 connection.features.supports_deferrable_unique_constraints
365 or "supports_deferrable_unique_constraints" in required_db_features
366 ):
367 errors.append(
368 checks.Warning(
369 f"{connection.display_name} does not support deferrable unique "
370 "constraints.",
371 hint=(
372 "A constraint won't be created. Silence this warning if you "
373 "don't care about it."
374 ),
375 obj=model,
376 id="models.W038",
377 )
378 )
379 if self.include and not (
380 connection.features.supports_covering_indexes
381 or "supports_covering_indexes" in required_db_features
382 ):
383 errors.append(
384 checks.Warning(
385 f"{connection.display_name} does not support unique constraints "
386 "with non-key columns.",
387 hint=(
388 "A constraint won't be created. Silence this warning if you "
389 "don't care about it."
390 ),
391 obj=model,
392 id="models.W039",
393 )
394 )
395 if self.contains_expressions and not (
396 connection.features.supports_expression_indexes
397 or "supports_expression_indexes" in required_db_features
398 ):
399 errors.append(
400 checks.Warning(
401 f"{connection.display_name} does not support unique constraints on "

Callers

nothing calls this directly

Calls 6

_check_local_fieldsMethod · 0.80
_get_expr_referencesMethod · 0.80
extendMethod · 0.80
_check_referencesMethod · 0.80
appendMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected