alias_mixin
AliasMixin
Used to translate field names into database column names.
Source code in ormar/models/mixins/alias_mixin.py
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
|
get_column_alias(field_name)
classmethod
Returns db alias (column name in db) for given ormar field. For fields without alias field name is returned. :param field_name: name of the field to get alias from :type field_name: str :return: alias (db name) if set, otherwise passed name :rtype: str
Source code in ormar/models/mixins/alias_mixin.py
14 15 16 17 18 19 20 21 22 23 24 25 |
|
get_column_name_from_alias(alias)
classmethod
Returns ormar field name for given db alias (column name in db). If field do not have alias it's returned as is. :param alias: :type alias: str :return: field name if set, otherwise passed alias (db name) :rtype: str
Source code in ormar/models/mixins/alias_mixin.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
|
translate_aliases_to_columns(new_kwargs)
classmethod
Translates dictionary of model fields changing aliases into field names. If field has no alias the alias is already a field name. Only fields present in the dictionary are translated. :param new_kwargs: dict with aliases and their values :type new_kwargs: Dict :return: dict with fields names and their values :rtype: Dict
Source code in ormar/models/mixins/alias_mixin.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
|
translate_columns_to_aliases(new_kwargs)
classmethod
Translates dictionary of model fields changing field names into aliases. If field has no alias the field name remains intact. Only fields present in the dictionary are translated. :param new_kwargs: dict with fields names and their values :type new_kwargs: Dict :return: dict with aliases and their values :rtype: Dict
Source code in ormar/models/mixins/alias_mixin.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
|