(cls, metadata)
| 1190 | class MutableWithScalarJSONTest(_MutableDictTestBase, fixtures.MappedTest): |
| 1191 | @classmethod |
| 1192 | def define_tables(cls, metadata): |
| 1193 | import json |
| 1194 | |
| 1195 | class JSONEncodedDict(TypeDecorator): |
| 1196 | impl = VARCHAR(50) |
| 1197 | cache_ok = True |
| 1198 | |
| 1199 | def process_bind_param(self, value, dialect): |
| 1200 | if value is not None: |
| 1201 | value = json.dumps(value) |
| 1202 | |
| 1203 | return value |
| 1204 | |
| 1205 | def process_result_value(self, value, dialect): |
| 1206 | if value is not None: |
| 1207 | value = json.loads(value) |
| 1208 | return value |
| 1209 | |
| 1210 | MutableDict = cls._type_fixture() |
| 1211 | |
| 1212 | Table( |
| 1213 | class="st">"foo", |
| 1214 | metadata, |
| 1215 | Column( |
| 1216 | class="st">"id", Integer, primary_key=True, test_needs_autoincrement=True |
| 1217 | ), |
| 1218 | Column(class="st">"data", MutableDict.as_mutable(JSONEncodedDict)), |
| 1219 | Column(class="st">"non_mutable_data", JSONEncodedDict), |
| 1220 | Column(class="st">"unrelated_data", String(50)), |
| 1221 | ) |
| 1222 | |
| 1223 | def test_non_mutable(self): |
| 1224 | self._test_non_mutable() |
nothing calls this directly
no test coverage detected