(cls, metadata)
| 1227 | class MutableColumnCopyJSONTest(_MutableDictTestBase, fixtures.MappedTest): |
| 1228 | @classmethod |
| 1229 | def define_tables(cls, metadata): |
| 1230 | import json |
| 1231 | |
| 1232 | class JSONEncodedDict(TypeDecorator): |
| 1233 | impl = VARCHAR(50) |
| 1234 | cache_ok = True |
| 1235 | |
| 1236 | def process_bind_param(self, value, dialect): |
| 1237 | if value is not None: |
| 1238 | value = json.dumps(value) |
| 1239 | |
| 1240 | return value |
| 1241 | |
| 1242 | def process_result_value(self, value, dialect): |
| 1243 | if value is not None: |
| 1244 | value = json.loads(value) |
| 1245 | return value |
| 1246 | |
| 1247 | MutableDict = cls._type_fixture() |
| 1248 | |
| 1249 | Base = declarative_base(metadata=metadata) |
| 1250 | |
| 1251 | class AbstractFoo(Base): |
| 1252 | __abstract__ = True |
| 1253 | |
| 1254 | id = Column( |
| 1255 | Integer, primary_key=True, test_needs_autoincrement=True |
| 1256 | ) |
| 1257 | data = Column(MutableDict.as_mutable(JSONEncodedDict)) |
| 1258 | non_mutable_data = Column(JSONEncodedDict) |
| 1259 | unrelated_data = Column(String(50)) |
| 1260 | |
| 1261 | class Foo(AbstractFoo): |
| 1262 | __tablename__ = "foo" |
| 1263 | column_prop = column_property( |
| 1264 | func.lower(AbstractFoo.unrelated_data) |
| 1265 | ) |
| 1266 | |
| 1267 | assert Foo.data.property.columns[0].type is not AbstractFoo.data.type |
| 1268 | |
| 1269 | def test_non_mutable(self): |
| 1270 | self._test_non_mutable() |
nothing calls this directly
no test coverage detected