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

Class TextField

tortoise/fields/data.py:259–304  ·  view source on GitHub ↗

Large Text field.

Source from the content-addressed store, hash-verified

257
258
259class TextField(Field[str], str): # type: ignore
260 """
261 Large Text field.
262 """
263
264 indexable = False
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"
299
300 class _db_mssql:
301 SQL_TYPE = "NVARCHAR(MAX)"
302
303 class _db_oracle:
304 SQL_TYPE = "NCLOB"
305
306
307class BooleanField(Field[T_BOOL]):

Callers 4

resolveMethod · 0.90
test_unique_failFunction · 0.90
test_index_failFunction · 0.90
test_pk_deprecatedFunction · 0.90

Calls

no outgoing calls

Tested by 3

test_unique_failFunction · 0.72
test_index_failFunction · 0.72
test_pk_deprecatedFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…