MCPcopy
hub / github.com/django/django / column_sql

Method column_sql

django/db/backends/base/schema.py:382–407  ·  view source on GitHub ↗

Return the column definition for a field. The field must already have had set_attributes_from_name() called.

(self, model, field, include_default=False)

Source from the content-addressed store, hash-verified

380 yield self._comment_sql(field.db_comment)
381
382 def column_sql(self, model, field, include_default=False):
383 """
384 Return the column definition for a field. The field must already have
385 had set_attributes_from_name() called.
386 """
387 # Get the column's type and use that as the basis of the SQL.
388 field_db_params = field.db_parameters(connection=self.connection)
389 column_db_type = field_db_params["type"]
390 # Check for fields that aren't actually columns (e.g. M2M).
391 if column_db_type is None:
392 return None, None
393 params = []
394 return (
395 " ".join(
396 # This appends to the params being returned.
397 self._iter_column_sql(
398 column_db_type,
399 params,
400 model,
401 field,
402 field_db_params,
403 include_default,
404 )
405 ),
406 params,
407 )
408
409 def skip_default(self, field):
410 """

Callers 3

table_sqlMethod · 0.95
add_fieldMethod · 0.95
_alter_fieldMethod · 0.45

Calls 3

_iter_column_sqlMethod · 0.95
db_parametersMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected