MCPcopy
hub / github.com/tortoise/tortoise-orm / get_for_dialect

Method get_for_dialect

tortoise/fields/base.py:428–447  ·  view source on GitHub ↗

Returns a field by dialect override. :param dialect: The requested SQL Dialect. :param key: The attribute/method name.

(self, dialect: str, key: str)

Source from the content-addressed store, hash-verified

426 }
427
428 def get_for_dialect(self, dialect: str, key: str) -> Any:
429 """
430 Returns a field by dialect override.
431
432 :param dialect: The requested SQL Dialect.
433 :param key: The attribute/method name.
434 """
435 try:
436 dialect_cls = getattr(self, f"_db_{dialect}") # throws AttributeError if not present
437 dialect_value = getattr(dialect_cls, key) # throws AttributeError if not present
438 except AttributeError:
439 pass
440 else: # we have dialect_cls and dialect_value, so lets use it
441 # it could be that dialect_value is a computed property, like in CharField._db_oracle.SQL_TYPE,
442 # and therefore one first needs to instantiate dialect_cls
443 if isinstance(dialect_value, property):
444 return getattr(dialect_cls(self), key)
445 return dialect_value
446 # If there is nothing special defined, return the value of self
447 return getattr(self, key, None)
448
449 def describe(self, serializable: bool) -> dict:
450 """

Callers 15

get_db_field_typeMethod · 0.95
get_db_field_typesMethod · 0.95
resolve_nested_fieldFunction · 0.80
resolveMethod · 0.80
_process_filter_kwargMethod · 0.80
resolve_orderingMethod · 0.80
_make_queriesMethod · 0.80
_get_pk_create_sqlMethod · 0.80
_get_table_sqlMethod · 0.80
_alter_fieldMethod · 0.80

Calls

no outgoing calls

Tested by 2

benchFunction · 0.64