(self, model, connection)
| 153 | ) |
| 154 | |
| 155 | def check(self, model, connection): |
| 156 | errors = [] |
| 157 | if not ( |
| 158 | connection.features.supports_table_check_constraints |
| 159 | or "supports_table_check_constraints" in model._meta.required_db_features |
| 160 | ): |
| 161 | errors.append( |
| 162 | checks.Warning( |
| 163 | f"{connection.display_name} does not support check constraints.", |
| 164 | hint=( |
| 165 | "A constraint won't be created. Silence this warning if you " |
| 166 | "don't care about it." |
| 167 | ), |
| 168 | obj=model, |
| 169 | id="models.W027", |
| 170 | ) |
| 171 | ) |
| 172 | elif ( |
| 173 | connection.features.supports_table_check_constraints |
| 174 | or "supports_table_check_constraints" |
| 175 | not in model._meta.required_db_features |
| 176 | ): |
| 177 | references = set() |
| 178 | condition = self.condition |
| 179 | if isinstance(condition, Q): |
| 180 | references.update(model._get_expr_references(condition)) |
| 181 | if any(isinstance(expr, RawSQL) for expr in condition.flatten()): |
| 182 | errors.append( |
| 183 | checks.Warning( |
| 184 | f"Check constraint {self.name!r} contains RawSQL() expression " |
| 185 | "and won't be validated during the model full_clean().", |
| 186 | hint="Silence this warning if you don't care about it.", |
| 187 | obj=model, |
| 188 | id="models.W045", |
| 189 | ), |
| 190 | ) |
| 191 | errors.extend(self._check_references(model, references)) |
| 192 | return errors |
| 193 | |
| 194 | def _get_check_sql(self, model, schema_editor): |
| 195 | query = Query(model=model, alias_cols=False) |
nothing calls this directly
no test coverage detected