Returns a field by dialect override. :param dialect: The requested SQL Dialect. :param key: The attribute/method name.
(self, dialect: str, key: str)
| 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 | """ |
no outgoing calls