alias_mixin
AliasMixin
Used to translate field names into database column names.
Source code in ormar/models/mixins/alias_mixin.py
| Python | |
|---|---|
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 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |
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
| Python | |
|---|---|
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | |
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
| Python | |
|---|---|
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | |
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
| Python | |
|---|---|
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |
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
| Python | |
|---|---|
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |