MCPcopy Create free account
hub / github.com/tortoise/tortoise-orm / __init__

Method __init__

tortoise/fields/data.py:267–295  ·  view source on GitHub ↗
(
        self,
        primary_key: bool | None = None,
        unique: bool = False,
        db_index: bool = False,
        **kwargs: Any,
    )

Source from the content-addressed store, hash-verified

265 SQL_TYPE = "TEXT"
266
267 def __init__(
268 self,
269 primary_key: bool | None = None,
270 unique: bool = False,
271 db_index: bool = False,
272 **kwargs: Any,
273 ) -> None:
274 if primary_key or kwargs.get("pk"):
275 warnings.warn(
276 "TextField as a PrimaryKey is Deprecated, use CharField instead",
277 DeprecationWarning,
278 stacklevel=2,
279 )
280 if unique:
281 raise ConfigurationError(
282 "TextField doesn't support unique indexes, consider CharField or another strategy"
283 )
284 if (index := kwargs.pop("index", None)) is not None:
285 warnings.warn(
286 "`index` is deprecated, please use `db_index` instead",
287 DeprecationWarning,
288 stacklevel=2,
289 )
290 if index or db_index:
291 raise ConfigurationError("TextField can't be indexed, consider CharField")
292 elif db_index:
293 raise ConfigurationError("TextField can't be indexed, consider CharField")
294
295 super().__init__(primary_key=primary_key, **kwargs)
296
297 class _db_mysql:
298 SQL_TYPE = "LONGTEXT"

Callers

nothing calls this directly

Calls 3

ConfigurationErrorClass · 0.90
getMethod · 0.45
__init__Method · 0.45

Tested by

no test coverage detected