How do i inherit mapped_column or Column Class to add additional column properties ? #11511
-
I understand Column class has a property called "info" which can be used to store additional metadata about the column , but i am interested to extend the Column class possibly inherit it and add some additional properties to it, how do i go about it in 2.0. Since in 2.0 its recommended to used mapped_column which in turn calls a MappedColumn class . I see mapped class is using the Column class to assign properties here how do i add my custom Column class here , or is there any better way to extend the Column Class to add additional properties ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Hi, This use case it not supported, at least at the moment. How so you intend to use the additional properties in an orm class? You are not usually using a table directly there. Do you have an example? |
Beta Was this translation helpful? Give feedback.
Sure, all previous orm mapping styles continue to be supported in v2.
The suggested is the one that uses Mapped and mapped_column because it's the one that best integrates with typing tools.
Note that I would instead use a function that abstracts how to get the custom props from a column or orm attribute. This way you could simply use a key in info