MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / conv

Class conv

lib/sqlalchemy/sql/elements.py:5909–5957  ·  view source on GitHub ↗

Mark a string indicating that a name has already been converted by a naming convention. This is a string subclass that indicates a name that should not be subject to any further naming conventions. E.g. when we create a :class:`.Constraint` using a naming convention as follows:

Source from the content-addressed store, hash-verified

5907
5908
5909class conv(_truncated_label):
5910 """Mark a string indicating that a name has already been converted
5911 by a naming convention.
5912
5913 This is a string subclass that indicates a name that should not be
5914 subject to any further naming conventions.
5915
5916 E.g. when we create a :class:`.Constraint` using a naming convention
5917 as follows::
5918
5919 m = MetaData(
5920 naming_convention={"ck": "ck_%(table_name)s_%(constraint_name)s"}
5921 )
5922 t = Table(
5923 "t", m, Column("x", Integer), CheckConstraint("x > 5", name="x5")
5924 )
5925
5926 The name of the above constraint will be rendered as ``"ck_t_x5"``.
5927 That is, the existing name ``x5`` is used in the naming convention as the
5928 ``constraint_name`` token.
5929
5930 In some situations, such as in migration scripts, we may be rendering
5931 the above :class:`.CheckConstraint` with a name that's already been
5932 converted. In order to make sure the name isn't double-modified, the
5933 new name is applied using the :func:`_schema.conv` marker. We can
5934 use this explicitly as follows::
5935
5936
5937 m = MetaData(
5938 naming_convention={"ck": "ck_%(table_name)s_%(constraint_name)s"}
5939 )
5940 t = Table(
5941 "t",
5942 m,
5943 Column("x", Integer),
5944 CheckConstraint("x > 5", name=conv("ck_t_x5")),
5945 )
5946
5947 Where above, the :func:`_schema.conv` marker indicates that the constraint
5948 name here is final, and the name will render as ``"ck_t_x5"`` and not
5949 ``"ck_t_ck_t_x5"``
5950
5951 .. seealso::
5952
5953 :ref:`constraint_naming_conventions`
5954
5955 """
5956
5957 __slots__ = ()
5958
5959
5960# for backwards compatibility in case

Callers 3

selected_columnsMethod · 0.85
wrap_legFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected