(self, parent: Mapper[Any], init: bool)
| 1037 | |
| 1038 | @util.preload_module("sqlalchemy.orm.properties") |
| 1039 | def set_parent(self, parent: Mapper[Any], init: bool) -> None: |
| 1040 | properties = util.preloaded.orm_properties |
| 1041 | |
| 1042 | if self.map_column: |
| 1043 | # implement the 'map_column' option. |
| 1044 | if self.key not in parent.persist_selectable.c: |
| 1045 | raise sa_exc.ArgumentError( |
| 1046 | "Can't compile synonym '%s': no column on table " |
| 1047 | "'%s' named '%s'" |
| 1048 | % ( |
| 1049 | self.name, |
| 1050 | parent.persist_selectable.description, |
| 1051 | self.key, |
| 1052 | ) |
| 1053 | ) |
| 1054 | elif ( |
| 1055 | parent.persist_selectable.c[self.key] |
| 1056 | in parent._columntoproperty |
| 1057 | and parent._columntoproperty[ |
| 1058 | parent.persist_selectable.c[self.key] |
| 1059 | ].key |
| 1060 | == self.name |
| 1061 | ): |
| 1062 | raise sa_exc.ArgumentError( |
| 1063 | "Can't call map_column=True for synonym %r=%r, " |
| 1064 | "a ColumnProperty already exists keyed to the name " |
| 1065 | "%r for column %r" |
| 1066 | % (self.key, self.name, self.name, self.key) |
| 1067 | ) |
| 1068 | p: ColumnProperty[Any] = properties.ColumnProperty( |
| 1069 | parent.persist_selectable.c[self.key] |
| 1070 | ) |
| 1071 | parent._configure_property(self.name, p, init=init, setparent=True) |
| 1072 | p._mapped_by_synonym = self.key |
| 1073 | |
| 1074 | self.parent = parent |
| 1075 | |
| 1076 | |
| 1077 | class Synonym(SynonymProperty[_T], _DeclarativeMapped[_T]): |
nothing calls this directly
no test coverage detected