class _WrapperColumn(object) A wrapper class, which wraps the individual description column object, to allow identify the duplicate column name, created by PostgreSQL database server implicitly during query execution. Methods: ------- * __init__(_col, _name) - Init
| 26 | |
| 27 | |
| 28 | class _WrapperColumn(object): |
| 29 | """ |
| 30 | class _WrapperColumn(object) |
| 31 | |
| 32 | A wrapper class, which wraps the individual description column object, |
| 33 | to allow identify the duplicate column name, created by PostgreSQL database |
| 34 | server implicitly during query execution. |
| 35 | |
| 36 | Methods: |
| 37 | ------- |
| 38 | * __init__(_col, _name) |
| 39 | - Initialize the wrapper around the description column object, which will |
| 40 | present the dummy name when available instead of the duplicate name. |
| 41 | |
| 42 | * __getattribute__(name) |
| 43 | - Get attributes from the original column description (which is a named |
| 44 | tuple) except for few of the attributes of this object (i.e. orig_col, |
| 45 | dummy_name, __class__, to_dict) are part of this object. |
| 46 | |
| 47 | * __getitem__(idx) |
| 48 | - Get the item from the original object except for the 0th index item, |
| 49 | which is for 'name'. |
| 50 | |
| 51 | * __setitem__(idx, value) |
| 52 | * __delitem__(idx) |
| 53 | - Override them to make the operations on original object. |
| 54 | |
| 55 | * to_dict() |
| 56 | - Converts original objects data as OrderedDict (except the name will same |
| 57 | as dummy name (if available), and one more parameter as 'display_name'. |
| 58 | """ |
| 59 | |
| 60 | def __init__(self, _col, _name): |
| 61 | """Initializer for _WrapperColumn""" |
| 62 | self.orig_col = _col |
| 63 | self.dummy_name = _name |
| 64 | |
| 65 | def __getattribute__(self, name): |
| 66 | """Getting the attributes from the original object. (except few)""" |
| 67 | if (name == 'orig_col' or name == 'dummy_name' or |
| 68 | name == '__class__' or name == 'to_dict'): |
| 69 | return object.__getattribute__(self, name) |
| 70 | elif name == 'name': |
| 71 | res = object.__getattribute__(self, 'dummy_name') |
| 72 | if res is not None: |
| 73 | return res |
| 74 | return self.orig_col.__getattribute__(name) |
| 75 | |
| 76 | def __getitem__(self, idx): |
| 77 | """Overrides __getitem__ to fetch item from original object""" |
| 78 | if idx == 0 and self.dummy_name is not None: |
| 79 | return self.dummy_name |
| 80 | return self.orig_col.__getitem__(idx) |
| 81 | |
| 82 | def __setitem__(self, *args, **kwargs): |
| 83 | """Orverrides __setitem__ to do the operations on original object.""" |
| 84 | return self.orig_col.__setitem__(*args, **kwargs) |
| 85 |
no outgoing calls
no test coverage detected