MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _dedupe_anon_label_idx

Method _dedupe_anon_label_idx

lib/sqlalchemy/sql/elements.py:1881–1902  ·  view source on GitHub ↗

label to apply to a column that is anon labeled, but repeated in the SELECT, so that we have to make an "extra anon" label that disambiguates it from the previous appearance. these labels come out like "foo_bar_id__1" and have double underscores in them.

(self, idx: int)

Source from the content-addressed store, hash-verified

1879 return self._anon_key_label
1880
1881 def _dedupe_anon_label_idx(self, idx: int) -> str:
1882 """label to apply to a column that is anon labeled, but repeated
1883 in the SELECT, so that we have to make an "extra anon" label that
1884 disambiguates it from the previous appearance.
1885
1886 these labels come out like "foo_bar_id__1" and have double underscores
1887 in them.
1888
1889 """
1890 label = getattr(self, "name", None)
1891
1892 # current convention is that if the element doesn't have a
1893 # ".name" (usually because it is not NamedColumn), we try to
1894 # use a "table qualified" form for the "dedupe anon" label,
1895 # based on the notion that a label like
1896 # "CAST(casttest.v1 AS DECIMAL) AS casttest_v1__1" looks better than
1897 # "CAST(casttest.v1 AS DECIMAL) AS anon__1"
1898
1899 if label is None:
1900 return self._dedupe_anon_tq_label_idx(idx)
1901 else:
1902 return self._anon_label(label, add_hash=idx)
1903
1904 @util.memoized_property
1905 def _anon_tq_label(self) -> _anonymous_label:

Callers 1

Calls 2

_anon_labelMethod · 0.95

Tested by

no test coverage detected